0

I have specified mongoengine model class with _id field as a StringField:

class Store(DynamicDocument):
    _id = StringField(primary_key=True, min_length=1)

And now when I query document by _id field I get document properly:

get by _id

I can get it by pk too:

enter image description here

but I cannot get it by id:

get by id

As you can see at the first screen there's id and pk fields initialized successfully. So I just can't make it out why mongoengine behaves like this. What am I doing wrong?

egvo
  • 1,493
  • 18
  • 26

1 Answers1

1

Try to declare your "_id" as "id":

class Store(DynamicDocument):
    id = StringField(primary_key=True, min_length=1)
4ndr3
  • 141
  • 1
  • 7