Closed SalmanZafar1105 closed 7 years ago
You can set documentIDs
to the replicator. Thanks.
I am using couchbase lite and not couchdb, mongodb, etc. Couchbase lite supports only channel based filter.
All my documents are in some channel(s). No document is in the public channel.
SO I CANNOT SYNC WITH documentIDs.
Have you tried using the documentIDs
method on the replication object as Pasin pointed out? If that doesn't solve your query can you explain why?
CBLHTTP[400, "bad_request", http://:*****@my:4990/db/_changes?feed=longpoll&heartbeat=300000&style=all_docs&since=1088&filter=_doc_ids]
I get this error.
It has something to do with channels. If a document is assigned a channel, I cannot pull it with documentIDs.
Can you try with a one-shot replication instead of continuous?
No error, but document is not synced.
In couchbase lite documentation, it is written that to filter documents from sync gateway we need to specify channels, but if we are using couchdb, pouchdb or cloudant then there are other methods.
The word "documentID" is not written in the replication part of couchbase lite documentation. Link -
I am asking, is there a better alternative if I want to sync just a single document.
The last sentence in this paragraph mentions filtering by doc ID and I agree we need a bit more content on that (specifically that it's not supported for continuous replications). Per https://github.com/couchbase/sync_gateway/issues/1703 and https://github.com/couchbase/sync_gateway/issues/1712 it should work though. Are you sure that user has access to the document?
I coordinated with the back-end team to check if I have access to the document. They said the document's channel should be in the user's admin channel.
The userId is 919711. The user document has the following channel -
"channels": { "ch-919711": null }
Also, user's admin channel contain this channel - "admin_channels":["ch-919711",...]
So, I have access to the document.
I just tried with the following and the replication pulled the doc successfully from SG:
let replication = database.createPullReplication(kSyncGatewayUrl)
replication.authenticator = CBLAuthenticator.basicAuthenticator(withName: "user1", password: "pass")
replication.documentIDs = ["456"]
replication.start()
after adding the doc:
curl -vX PUT 'http://user1:pass@localhost:4984/todo/456' -H 'Content-Type: application/json' -d '{}'
We'll update the documentation to make that clearer so thanks for the feedback!
@SalmanZafar1105, sorry about this. I don't know that SGW doesn't currently support docIDs in continuous replication. Meanwhile, you might need to setup the timer to periodically start a single shot pull replicator.
It's OK. I have it working now.
Sync documents by specifying document IDs.
As of now, filter pull is done by specifying channels. We have to run a separate pull replication for one single document.
How to pull one document from sync gateway?