Views in Couchbase
I have a couchbase server and I am trying to create some views, but it seems that I don't have a complete understanding of the concept of views. I have the following two sample documents:
{
"id": 70,
"status": 2,
"updatedAt": "2014-09-04T08:52:29.969Z",
"createdAt": "2014-09-03T21:32:19.000Z",
"user1": {
"id": 33185,
....
},
"user2": {
"id": 40838,
.....
}
}
{
"id": 71,
"status": 4,
"updatedAt": "2014-09-03T21:33:09.404Z",
"createdAt": "2014-09-03T21:32:20.000Z",
"user1": {
"id": 37126,
....
},
"user2": {
"id": 36094,
.....
}
}
when i create a view using this map function:
function (doc, meta) {
if (doc.user1 && doc.user2) {
emit(doc.id, doc);
}
}
the first document (with id: 70) is not returned by the view, and the second. I didn't understand why, although both have user1 and user2.
Any help is greatly appreciated.
+3
source to share