Example #1
0
    def update(self, object_id: str, object_model: Model) -> dict:
        try:
            json = object_model.to_json()
        except AttributeError:
            json = object_model

        return self._mongo_database.mongo_db[self.collection].update_one(
            {'_id': ObjectId(object_id)}, {"$set": json})
Example #2
0
 def create(self, model: Model) -> str:
     json = model.to_json()
     object_id = self._mongo_database.create(self.collection, json)
     return object_id