I'm working with mongoengine in Django,
this is my document defination:
class Location(mongoengine.Document):
user_id = mongoengine.IntField(required=True)
point = mongoengine.GeoPointField(required=True)
I want to do this:
given a user_id
and a point
:
if there is no document that have this user_id
, create one with the user_id
and point
and save it;
else update the document with user_id
with point
.
Can I do this in one statement with mongoengine?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…