예제 #1
0
 def updateMap(self, m: Map) -> Map:
     if len(m.id) != 24:
         return m
     result = mapCol.update_one({'_id': ObjectId(m.id)},
                                {'$set': m.toDBMap()},
                                upsert=True)
     if result.upserted_id:
         m.id = str(result.upserted_id)
     return m
예제 #2
0
 def saveMap(self, m: Map) -> Map:
     result = mapCol.insert_one(m.toDBMap())
     m.id = str(result.inserted_id)
     return m
예제 #3
0
 def assembleMap(self, item: dict) -> Map:
     m = Map(item)
     m.id = str(item['_id'])
     return m