Query to have created, deleted, update records

Hi,

Based on the Xamarin example I am creating a layer that does something similar to what is possible with Firebase. There I have the possibility to get hold of created, updated and deleted records compared to the local cache. Is there a way to do this with couchbase as well with the query builder?

Kind regards,

Rob

“Local” isn’t a cache in CBL; it is your database. There isn’t a way to access the server database directly.

You can use the Replicator listener API to be notified of documents being updated during replication, if you want to know what’s changed.

Thanks. With a change listener on the database I can get the changed ids. But finding a deleted document according to the documentation is distinquished by checking if the id can be gotten by GetDocument. But elsewhere I read about a IsDeleted flag so then I wonder if GetDocument should not return the deleted document. I would like to find out what document was been deleted (I am using documen with type properties).

The database change listener won’t tell you whether a changed document was deleted, which is unfortunate. But if you try to get the document and get a not-found error, that means it was deleted.

The Replicator’s document-change listener does tell you whether a document was deleted, though. So it’s easier to detect this for incoming changes from the server.

To add to what Jens said, here is a code snippet of using a document replication listener to detect if a deleted document was replicated .

Can I add listeners after the replicatior has started? It appears events are not firing when adding events after the replicator has started.

No. Any reason why you would want to do that ?