Sync Gateway _changes questions


#1

UPDATE - ignore this question, I now see it was the couchbase lite documentation I was in. It would be great in the future if there was a way to delete a topic in the forum.

Hi, I have a few questions about the sync gateway _changes function, based on the documentation for it here: http://developer.couchbase.com/mobile/develop/references/couchbase-lite/rest-api/database/get-changes/index.html

  1. What are filter functions? The documentation lists filter as a parameter I can specify and just says this: “reference to a filter function from a design document that will filter whole stream emitting only filtered events.” view is listed as a separate param so I’m assuming a filter function is not just a view, but I can’t find any documentation about filter functions in couchbase.

  2. I tried using descending=true and limit=1 to get only the latest change, but it seemed to ignore the descending flag and just returned the same document it returns if I don’t specify descending, and it just returns the last_seq number of that document and not of the latest change. Basically I want to get the latest last_seq number as fast as possible without retrieving a ton of documents. Even with limit=1 the call still takes about 5 seconds to run for a user with less than 10000 documents.


#2

Hey @alexegli,

Will surface this up as a feature request to have remove functionalities.

And again you may find the answers to the Sync Gateway over at the section regarding Filter Functions

Could you provide some code for your second question? You can retrieve the document’s last revision_id via the Revision class and proceed from there.


#3

Thanks for the info. This was regarding the sync gateway REST API _changes call but I was reading the wrong documentation and was looking at the couchbase lite REST API. I was trying to get the last_seq value for a user out of all their documents without actually retrieving all the documents. I have another topic in this forum opened about that question though.