Unable to retrieve data though it's on the couchbase server

I have an interesting issue. I am working on a iOS app which uses couchbase synch gateway and server on the localhost. (I also installed it remotely as well but in order to examine the data on the synch gateway, I used the localhost as mentioned in the couchbase documentation)

I am able to create, save and later retrieve data from couchbase server just fine. And I can see the data on the portal. However, when I tested the scenario where I delete the app and then reinstall, I can no longer able to retrieve the data which are already on couchbase server. I verified that those previously saved data still exist.

I also log the replication (push and pull) to make sure that they are both active which they are.

If I use the app to create and save new data, it also works… which means I can create, save, and retrieve the new data. However, I have lost the ability to retrieve the previously saved data that still exist on couchbase.

Does deleting and reinstall the app cause new session? I am confused. Please help.

Most likely the sync function isn’t assigning the docs to any channel that you client can access, i.e. the client can’t read any docs from the server.

If I use the app to create and save new data, it also works… which means I can create, save, and retrieve the new data.

No, that doesn’t mean you can retrieve data, only that you can save it. The app has its own replica of the database so it doesn’t need to read back any docs that it pushes to the server.

Hi Jens,

You are right. I didn’t assign to any channel. This is my config.son (hiding the password). Can you recommend how I can assign to the channel? (or sample config)

Thank you.

{
“interface”:":4984",
“adminInterface”:":4985",
“log”:[“REST”],
“databases”:{
“elate-synch”:{
“server”:“http://localhost:8091”,
“bucket”:“elate-synch”,
“sync”:function(doc) {channel(doc.channels);},
“users”: {
“Administrator”: {
“admin_channels”: [“all”],
“admin_roles”: [“froods”],
“password”: “*****”
},
“GUEST”: {“disabled”: true}
},
“roles”: {
“froods”: {“admin_channels”: [“hoopy”]}
}
}
}

}

The easiest way is to change "all" to "*". That will give the Administrator user access to all documents.

Alternatively you could change your client code to add the property "channels":["all"] to each document. That will add the doc to the all channel that you’ve already given your account access to.

Thank you, Jens. I am able to retrieve the data now using channels.