Changes feed skipping the documents those are created using collections

Hi,
I am unable fetch the documens that created to collection directly using ths sync gateway

Screenshot 2024-08-01 at 3.20.11 PM

And also those documents are skipped in the changes feed

{“results”:[
{“seq”:2,“id”:“_user/nodeserver”,“changes”:}
,{“seq”:3,“id”:“1c33107248ce26511ebbaf027a0e6ad8”,“changes”:[{“rev”:“1-2159404f15e6bd686b6a3cbb1adff670”}]}
,{“seq”:4,“id”:“1c33107248ce26511ebbaf027a0e6ad812”,“changes”:[{“rev”:“1-2159404f15e6bd686b6a3cbb1adff670”}]}
,{“seq”:1189209,“id”:“gh_util_operator_navigation:restrictedugqa”,“changes”:[{“rev”:“26-68fefa5acfc20c77b9e30f4326ec0791”}]}
,{“seq”:1237376,“id”:“d9d214e5-0942-4fee-8c78-afd1d6d84d86”,“changes”:[{“rev”:“1-1eb11dd74e5f33cfb963d6c2c65798e2”}]}
,{“seq”:1413590,“id”:“614928cefe6ed2554ee76ededac09563”,“changes”:[{“rev”:“1-ee09c0227dc1f781a4e0a84af957bcba”}]}
,{“seq”:1413593,“id”:“be9d010430820bdd5e42d9700300f573”,“changes”:[{“rev”:“1-ee09c0227dc1f781a4e0a84af957bcba”}]}
],
“last_seq”:“1413593”}

Your URL is referring to the _default collection implicitly by only specifying the database name (/gh-ucil-test/)

You need to specify which scope/collection you want to retrieve your document from in the Sync Gateway API route. E.g: /gh-ucil-test._default.dbc_task/

You can find this info under the “keyspace” description in the API docs:

Similarly, the changes feed is also keyspace-specific:

Thank you for the response.

Question 1:

How can I use the changes feed so that all documents appear in the feed, irrespective of changes? How do I call the changes feed for all collections?


Question 2:

I am trying to fetch documents based on the channels using _changes?filter=sync_gateway/bychannel&channels=*&collection=_default.dbc_user,_default.dbc_locations, but nothing is appearing. i have channles update in the couchbase and used below config to create a sg user

curl --location -g --request POST 'http://localhost:4985/test/_user/'      --header 'Content-Type: application/json'      --header "Authorization: Basic $DIGEST"      --data-raw '{
         "name": "username", 
         "password": "passowrd",
         "admin_channels": ["*"]
     }’

``

Do i need to add anythinng in the create user config.

@bbrks

I have fetched created user from the SG


{"collection_access":{"_default":{"dbc_man_hours_locations":{"all_channels":["!"]},"dbc_telemetry_device":{"all_channels":["!"]}}}

This means that user do no not have permission to get the collection information?
pull replication was not happing with couch base lite because

Changes: c:[176b8107] db:gh-ucil-test col:dbc_util_operator_navigations Channels [ config ] request without access by user nodeserver

Use the since=0 parameter (which is the default value) to fetch all current document revisions. If you want document contents included in the feed, there’s also include_docs=true.
You cannot get a changes feed for multiple collections. Do one at a time programatically.

collection is not a valid query parameter. See the link I left above earlier for the changes API spec. You must specify collection with the keyspace in the path as described.

You need to grant the user access to the “config” channel, or all channels inside the dbc_util_operator_navigations collection.

Channels are collection-specific. The GET user response snippet you showed is showing the user only has access to the ! channel in both collections, and so would only see documents routed to that public channel.

If you’ve not already, I would highly recommend reading this blog post about Scopes and Collections in Couchbase Mobile. It should help

1 Like