Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB, how to get document changes only

Using /_changes?filter=_design I can get all the changes for design documents.

How do I get all the changes for documents only?

Is there such a thing like /_changes?filter=_docs_only ???

like image 522
Telemat Avatar asked May 18 '14 10:05

Telemat


1 Answers

There is no built in filter for this. You will need to write your own filter function (http://couchdb.readthedocs.org/en/latest/couchapp/ddocs.html#filterfun) that excludes design documents (check the doc's _id for "_design/", etc.) from the feed. You then reference this filter function when you query the changes feed (http://couchdb.readthedocs.org/en/latest/api/database/changes.html?highlight=changes). However, most applications don't run into this too often since design documents are typically only updated when there is an application change.

It would probably be more efficient to implement this filter on the client side instead of streaming all your changes to the couchjs process (always inefficient). As your application loops through the changes simply check whether it is a design doc there.

Cheers.

like image 121
Sam Bisbee Avatar answered Oct 06 '22 21:10

Sam Bisbee