Exemple #1
0
def findLatestRecords(col: collection.Collection, *strategyIds):
    records = []
    for sid in strategyIds:
        doc = col.find_one({"strategyId": sid}, sort=[("datetime", -1)])
        doc.pop('_id')
        if doc:
            records.append(doc)

    return pd.DataFrame(records).set_index("strategyId")
Exemple #2
0
 def find_one(self, spec_or_id=None, *args, **kwargs):
     """Like :meth:`~pymongo.collection.Collection.find_one` but sets the
     `as_class` attribute to the class of the calling model and spec_or_id
     can optionally be a string.
     """
     if isinstance(spec_or_id, basestring):
         spec_or_id = ObjectId(spec_or_id)
     kwargs['as_class'] = self.as_class
     return BaseCollection.find_one(self, *args, **kwargs)
 def find_one(self, spec_or_id=None, *args, **kwargs):
     """Like :meth:`~pymongo.collection.Collection.find_one` but sets the
     `as_class` attribute to the class of the calling model and spec_or_id
     can optionally be a string.
     """
     if isinstance(spec_or_id, basestring):
         spec_or_id = ObjectId(spec_or_id)
     kwargs['as_class'] = self.as_class
     return BaseCollection.find_one(self, *args, **kwargs)
 def find_one(self, *args, **kwargs):
     #if it's a single argument and a string, convert it to an objectid
     if len(args) == 1 and isinstance(args[0], basestring):
         args = ({u'_id': ObjectId(args[0])},)
 
     result = Collection.find_one(self, *args, **kwargs)
     if not result is None:
         return CSObject(getattr(winter.objects, self.name)(result), self.name)
     return result
Exemple #5
0
 def _dict(self) -> dict:
     """Return the dictionary form of the post."""
     return Collection.find_one(self._collection, {"_id": self._id})