Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View to get _changes with specific values

Tags:

couchdb

I can get the latest changed document by using:

localhost:5984/_changes

and then use the documentID's returned and obtain the document using

localhost:5984/documentID

I was wondering if I can combine them into a view - the view would execute _changes, get the document with the specific documentIDs and return those

like image 565
sami Avatar asked Jun 20 '11 08:06

sami


1 Answers

Changes queries can also include the entire document if you add a ?include_docs=true parameter.

To see only some documents instead of all of them, you can use filter functions: http://guide.couchdb.org/draft/notifications.html#filters

When calling a filtered _changes feed, you can also provide parameters, i.e.

 localhost:5984/db/_changes?include_docs=true&filter=foo/docs&id=docid

Using as filter:

function(doc, req)
{
  if(doc._id == req.query.id) {
    return true;
  }

  return false;
}

This will return only those documents matching the filter, including the document bodies.

like image 114
b_erb Avatar answered Oct 03 '22 18:10

b_erb