Reputation: 1136
I have a CouchDB View to return all documents meeting a certain criteria. I have also run "all_docs" against this same DB. In this particular case, my View returns 845 docs while all_docs returns 1127 docs.
Is there a way to code a View to effectively do the inverse, and return all documents NOT meeting my specified criteria? since my DB contains 1127 total docs and my View contains 845 docs, how do I identify the 282 difference?
Upvotes: 1
Views: 320
Reputation: 3690
You can either have two views or one single view.
function(doc){
var matchMyCriteria = doc.type ==="person";
emit(matchMyCriteria);
}
If I want every document document that are of type "person", I query:
_design/docname/_view/by_person?key="true"
If I want the every other documents
_design/docname/_view/by_person?key="false"
function(doc){
if(doc.type == "person")
emit(doc.id);
}
function(doc){
if(doc.type != "person")
emit(doc._id);
}
Upvotes: 1