jofftiquez
jofftiquez

Reputation: 7708

Couchbase nodejs how to retrieve data from sync gateway bucket to server bucket

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 restful-sample 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.

Upvotes: 1

Views: 604

Answers (1)

Geoffrey Marizy
Geoffrey Marizy

Reputation: 5521

There isn't a lot of documentation on bucket shadowing because this feature is kinda deprecated.

The recommended way of accessing Sync Gateway data from server is by leveraging the Sync Gateway REST API. With this API you can perform CRUD operations or access view. It's much less convenient than accessing Couchbase server with an SDK I agree, and a lot of feature are mising (N1QL for example).

Upvotes: 0

Related Questions