I\'m working with mongoengine in Django, this is my document defination:
class Location(mongoengine.Document): user_id = mongoengine.IntField(req
Note that get_or_create is now scheduled to be deprecated, because with no transaction support in MongoDB it cannot ensure atomicity.
get_or_create
The preferred way is update with upsert:
Location.objects(user_id=user_id).update_one(set__point=point, upsert=True)
More on upserts on the MongoDB documentation.