bicccio
bicccio

Reputation: 394

Couchdb query with AND operator

Is it possible to simulate this query with couchdb views?

select * from table where key1 = 'value 1' AND key2 = 'value 2';

Upvotes: 0

Views: 288

Answers (1)

Matt Jennings
Matt Jennings

Reputation: 1148

Yes. Your map function will look like this:

function(doc){
  if ( doc.key1 && doc.key2 ){
    emit([doc.key1, doc.key2], null);
  }
}

And then you would query it like this:

.../myview?startkey=["value 1","value 2"]&endkey=["value 1","value 2"]

Upvotes: 3

Related Questions