user6452148
user6452148

Reputation:

How to update a dictionary field's key of a document using monogoengine?

I am trying to update a key of a DictField using monogoengine update_one() method. what should the set__field be?

Articles.objects(id=request.data['id']).update_one()

for the field

something{'to_be_updated_key' : false}

Upvotes: 1

Views: 49

Answers (1)

bagerard
bagerard

Reputation: 6374

Syntax should be set__{dictfield_name}__{key}:

class FancyDoc(Document):
    dic = DictField()

doc = FancyDoc(dic={'key1': 1, 'key2': 2}).save()
FancyDoc.objects(id=doc.id).update_one(set__dic__key2=99)

Upvotes: 1

Related Questions