qiboteam / qibodb

Apache License 2.0
2 stars 0 forks source link

Impose uniqueness #10

Open alecandido opened 1 year ago

alecandido commented 1 year ago

There are collections in which it makes sense not to insert records, if a certain value is already contained. E.g. the package collection, for which it does not make sense to have multiple entries for the same version.

In SQL the UNIQUE attribute is doing exactly this. There should be a way to do it even in MongoDB, let's just check if it's convenient, or better to manually search.

https://www.mongodb.com/docs/manual/core/index-unique/ https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.create_index