INNER CODE UNIT · Python
connect_mongo
jsbroks/coco-annotator · backend/database/__init__.py:17
def connect_mongo(name, host=None):
if host is None:
host = Config.MONGODB_HOST
connect(name, host=host)
# https://github.com/MongoEngine/mongoengine/issues/1171
# Use this methods until a solution is found
def upsert(model, query=None, update=None):
if not update:
update = query
if not query:
return None
found = model.objects(**query)