I am looking for a workaround for primary key feature in couchdb. I am saving doc in json format to couchdb externally. Is there any simple way to check if value of a particular field exists?
Asked
Active
Viewed 163 times
0
-
1I'm not sure what you're trying to "work around". What is the problem? – Jonathan Hall May 01 '18 at 13:35
2 Answers
0
If you try to save a document that already exists, it will be rejected unless the revision is set to match the existing revision.
Alternately, you can just try to fetch the document, either with GET or HEAD, to check if it exists. See the relevant documentation.

Jonathan Hall
- 75,165
- 16
- 143
- 189
0
You could perform a mango query previous to the document creation but it will not warranty that another process create a document between the check and the creation.
This post discusses about the same issue:
How to check for duplication before creating a new document in CouchDB/Cloudant?

Juanjo Rodriguez
- 2,103
- 8
- 19