0

Is there any way to apply unique constraint in couchdb?

Suppose I have a document which have some fields like email, emp_id, phone_number that needs to be unique throughout the document. I could not find any way. Anyone knows how to achieve this?

Any answer/suggestion would be appreciated.

Akshay Sood
  • 6,366
  • 10
  • 36
  • 59
  • Possible duplicate of [Couchdb - how to set a field containing unique key](https://stackoverflow.com/questions/21531624/couchdb-how-to-set-a-field-containing-unique-key) – Jonathan Hall Apr 24 '18 at 12:10

2 Answers2

1

The only unique constraint in CouchDB is on the document ID. If you can put the unique components of your data in the document ID, then you have a uniqueness constraint.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
1

after a lot of searching, I found that If you want to add a unique constraint to only one parameter you can set it as id. But If there are multiple parameter that needs to be unique, then this is not possible in couchdb

Debut Infotech
  • 472
  • 5
  • 17