Is it possible to create a document on Couchbase Lite on a device then have it not synced to couchbase through the gateway. I need to sync certain documents only and not all the documents on Couchbase Lite.
Yes, you can. Which version of Couchbase Lite are you using ?
In 1.x there is localDocument that you can use
In 2.0, two options -
- Use a separate CBL instance that’s for local documents and is not attached to a replicator or synced
- Use documentIds property on
ReplicatorConfiguration
to specific the list of Ids to push/pull
Thanks. I am using CBL version 1.5, let me look at the localDocument documentation.
I should have mentioned- the options mentioned in 2.0 will work for 1.4/1.5 as well. It’s probably better to use the 2.0 ones since the localDocument is deprecated in 2.0 - so better to just design your app to be future proof
Be aware that “localDocuments” in 1.x aren’t equivalent to real documents. They’re simply places to store some JSON dictionaries. They aren’t accessible through the normal documents API, and they can’t be queried.
(This feature was based on the _local
doc namespace in CouchDB, which was mostly used to store replicator checkpoints. We’ve removed it in 2.0.)
In Couchbase Lite 1.x the best way to keep a document from being replicated is to set a push filter on the replication, which is a callback that you can make return false for the doc(s) you don’t want to replicate. For instance you could make it reject any doc whose ID begins with “local”. (2.0 doesn’t have push filters but I imagine they’ll get added back in an upcoming release.)