Mongoengine unique_with
You can specify indexes in the meta dict of the class
meta = {
'indexes': [
{'fields': ('merchant_id', 'order_id'), 'unique': True}
]
}
If you want to modify an existing index's parameters, you have to drop the index first and then recreate it. Of course you cannot create a unique index on collections that contain duplicates. Either you must remove the duplicates first, or use the 'dropDups' index creation option.