I have a View in Couchbase that I use to retrieve my data. Simplified, my data bucket contains:
{
"id" : 123,
"key" : "some value"
},
{
"id" : 456,
"key" : ""
}
...
and I want to get all the docs where 'key' is present, but its value is empty.
If I use a view like this:
function (doc, meta) {
if(doc.key)
emit([doc.id], doc);
}
I get both the JSONs above, if I use a view like this:
function (doc, meta) {
if(doc.key && doc.key == "")
emit([doc.id], doc);
}
I get none of them. I want to get the json with id = 456. What is the correct syntax?