How to retrieve data from sync gateway bucket to server bucket

connections
query
n1ql

#1

I dont know if this is the right place for this, but there’s not much help from stackoverflow so yah, sorry in advance. Thanks as well.

So I have this config.json on my couchserver running locally on my machine.

{
    "couchbase": {
        "server": "127.0.0.1:8091",
        "bucket": "restful-sample",
        "username": "restful-sample",
        "password": "123456"
    }
}

And this syncgw-config.json as the sync gateway setup.

{
    "interface": ":4987",
    "adminInterface": ":4988",
    "log": ["CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Shadow", "Shadow+", "Changes", "Changes+"],
    "databases": {
        "mycure": {
            "server": "http://localhost:8091",
            "bucket": "sync_gateway",
            "sync": `function(doc) {channel(doc.channels);}`,
            "users": {
                "GUEST": {
                    "disabled": false,
                    "admin_channels": ["*"]
                }
            },
            "shadow": {
                "server": "http://localhost:8091",
                "username": "restful-sample",
                "bucket": "restful-sample",
                "password": "123456"
            }
        }
    }
}

Good news is I can insert data to my restful-sample bucket and have it synced or “shadowed” to my mobile using the above sync gateway setup. Everything works fine, every data inserted is being synced to the mobile app.

But the bad news is, it’s not working vise versa, when I add data from the mobile app those data is not being synced automatically to the server bucket, but those data are being inserted to the sync gateway bucket successfully. Am I missing some config? I gotta be honest here, I dont think couchbase’s documentations are that clear.

BTW I followed this fine cean-stack tutorial in case you wanna see the actual queries happening on the server.