Unable to Create Index on Two IDs in MongoDB Schema #68
Unanswered
kumawat18020
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hi @kumawat18020 Did you add https://mongoz.dymmond.com/documents/?h=auto#creation-of-the-indexes? Also, there is this: https://mongoz.dymmond.com/documents/?h=auto#index-operations |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I'm working with a MongoDB schema using mongoz and trying to create a index on two fields (id1 and id2).
Code:
class Demo(BaseDocument):
id1: ObjectId = mongoz.ObjectId()
id2: ObjectId = mongoz.ObjectId()
Issue:
• The schema has only two fields (id1 and id2).
• I want to create a unique compound index on these two fields, but the index creation is not working as expected.
• No specific error is being thrown, but the index is not created.
How can I correctly define a index on two fields (id1 and id2) in a mongoz schema?
Beta Was this translation helpful? Give feedback.
All reactions