Does CouchbaseClient.Query take a snapshot of the data?


#1

Say I have a view with a reduce function that gives count of documents, and I get a ViewResponse by calling client.Query() with includeDocs set to true. Then I iterate the ViewResponse and use the count got from the view. Can I iterate the same ViewResponse object again sometime later to stamp a mark on the documents that were included in the view thus already counted? Will l get the same set of documents, assuming no documents are deleted or expired?

In between the two iterations, there’re new documents added that will be indexed by the view. What I want is that the second iteration of ViewResponse does not include them. Is this supported?


#2

I’m not completely sure what you mean, but the Response is based on the time you run query. When you rerun the query the ViewResponse will represent the current state of the index so it might have changed because new documents where written or just indexed after you queried last time.

If you keep the ViewResponse around it will not change after it is returned of course since the include_docs already loaded the documents they will all be in there, but no new ones unless you rerun the query.

Is that what you mean? Could you maybe give some example code and behaviour you would expect?