1

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.

jofftiquez
  • 7,548
  • 10
  • 67
  • 121
  • When you say "not being synced automatically to the server bucket" do you mean the sync_gateway bucket or the restful-sample bucket? You shouldn't expect it to go to the latter, only the former. – borrrden Jun 22 '16 at 06:50
  • Oh sorry, yes to the `restful-sample` bucket, the data was inserted to the `sync_gateway` but not to the `restful-sample`. @borrrden So how do I make it sync? – jofftiquez Jun 22 '16 at 07:31
  • 1
    I think I was wrong about the last part. The wiki page on bucket shadowing does imply that it does both ways. However, you might be setting yourself up for a lot of grief if you are using this for a new project. Have you considered using PouchDB instead? It is a javascript implementation of a database that is compatible with couchbase lite / sync gateway. Bucket shadowing is a way to leverage existing data into a new project, not create a new project. – borrrden Jun 23 '16 at 21:03
  • Also see if the logs say anything. – borrrden Jun 23 '16 at 21:07
  • @borrrden I get your point thanks. But I thought shadowing was a means of syncing backend existing data to the mobile app? Anyways my problem is getting the data from the sync gateway bucket that was added by the app. Any idea? – jofftiquez Jun 25 '16 at 06:32
  • Yes, that's what it is for. However your naming makes it seem like you are starting a new project. Maybe you are just practicing for your real existing data though? You should ask this question on the Couchbase Forums instead in the mobile category because I don't know much about bucket shadowing actually. Also be sure to check the logs for anything suspicious. – borrrden Jun 25 '16 at 06:53
  • @borrrden I posted a question to couchbase forum as well but no one's noticing lol. Anyways thanks for the answer :) – jofftiquez Jun 25 '16 at 08:04

1 Answers1

0

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).

Geoffrey Marizy
  • 5,282
  • 2
  • 26
  • 29