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


2 answers


You need to promote the document to be the design document that is its development. Project design documentation only works on a subset of the data.



+4


source


Keep in mind that design views are designed to design the view itself and only see a subset of the data. If you have this so that the view works the way you want it, you advertise the view as a production view so that it works against the entire dataset.



0


source







All Articles