Storing an instance with only primary_key set doesn't store the document. If any other field is set apart from primary_key the document is getting stored.
This must be happening as mongoengine assuming it to be update and as the instance has no other data set, hence mongoengine is getting northing in updates and removals.
Eg:
class Sample(Document):
key = StringField(primary_key=True)
count = IntField()
sample = Sample()
sample.key = "123"
sample.save() # does nothing
sample.count = 0
sample.save() # saves the document
I know I can use force_insert in save to make it work. but is this the desired behaviour?
Storing an instance with only
primary_keyset doesn't store the document. If any other field is set apart fromprimary_keythe document is getting stored.This must be happening as mongoengine assuming it to be update and as the instance has no other data set, hence mongoengine is getting northing in
updatesandremovals.Eg:
I know I can use
force_insertin save to make it work. but is this the desired behaviour?