Get a document with a specific field value in CouchDB?

I want to check if a document with a specific address exists.

How can i do this?

+8
couchdb
source share
3 answers

You can create a view with email as a key and request that view for a specific email address. Which values ​​are appropriate for the presentation depends on what you are going to do with the results. For example, you can select the number of documents containing an email address as view values.

This is a brief introduction to the views: http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views

+6
source share

Here's the idea for a map function in your view ( _design/foo ):

 function (doc) { if (doc.email) { emit(doc.email, null); } } 
+1
source share

CouchDB release 2.0.0 already provides a simple JSON method for executing CouchDB queries without MapReduce. More information can be found in the _ find, _index and _explain API

+1
source share

All Articles