예제 #1
0
 def get(cls, _id):
     try:
         _id = ObjectId(_id)
     except Exception:
         pass
     # result = DB.read_one(cls.collection, {'_id': ObjectId(_id)})
     result = DB.read_one(cls.collection, {'_id': _id})
     if result: return cls(result)
     return None
예제 #2
0
 def read(cls, query, many=False):
     if many:
         return [
             cls(record) for record in DB.read_many(cls.collection, query)
         ]
     else:
         record = (DB.read_one(cls.collection, query))
         if record: return cls(record)
     return None