Reputation: 93
The _changes document is not clear on the filter
and view
parameters, in Couchbase Lite. I am trying to query the below url to fetch changes if a document with type order gets added.
_changes?include_docs=true&feed=longpoll&since=0&filter=_view&view=orders%2Forder
This filter=_view&view=orders%2Forder
query parameter is the issue, removing the same from the above fetches all the documents
Using the above gives a 404 on Couchbase Lite but the same works on CouchDB. Response:
{
status: 404,
error: "not_found"
}
Here is my _design/orders
{
"_id": "_design/orders",
"language": "javascript",
"views": {
"order": {
"map": "function(doc) {if(doc.type && doc.type == 'order') {emit(doc.oID, doc);}}"
}
}
}
Please can any one share a syntax or example on how to pass the design document and/or view in _changes API to get a filtered output.
Upvotes: 0
Views: 160
Reputation: 142
Everyone who finds this, I think the answer could be changing the filter itself and the query string like this:
Filter:
{
"_id": "_design/orders",
"language": "javascript",
"filters": {
"order": "function(doc) {if(doc.type && doc.type == 'order') {emit(doc.oID, doc);}}"
}
}
and the query string:
_changes?include_docs=true&feed=longpoll&since=0&filter=orders/order
Upvotes: 0