2

I wrote an android app to create a Couchbase Lite database according to this tutorial and it works correctly from what Log shows.

I also Installed Couchbase Serever and created a bucket named "mycouchbasedb" as shown:enter image description here

When I run Sync gateway using the following config file:

{
"databases": {
  "db": {
    "bucket": "mycouchbasedb",
    "username": "admin",
    "password": "123456",
    "server": "127.0.0.1:8091",
    "enable_shared_bucket_access": true,
    "import_docs": "continuous"
   }
 }
}

I get the following error:

404 no such database "mycouchbasedb"  (0.0 ms)

1-What is the problem?

2-What is the difference between Bucket and Database in couchbase?

Hod
  • 2,236
  • 1
  • 14
  • 22
Mdeh
  • 451
  • 4
  • 8
  • What versions of CBL and Sync Gateway are you using? – Hod Feb 20 '18 at 17:23
  • Are you observing this error on Couchbase Lite Android side ? What do the SGW logs show? – rajagp Feb 20 '18 at 17:37
  • SGW logs shows this error, I'm using CBL version 1.3.1 and Sync Gateway version 1.5.1 – Mdeh Feb 20 '18 at 18:02
  • I tried this with SG 1.5.1 and Couchbase Server Enterprise Edition 5.0.1 build 5003 using your posted config and can't reproduce the problem. Any other info you can provide? Can you post the SG startup logs? – Hod Feb 21 '18 at 19:44

2 Answers2

4

That's because the name of your Sync Gateway database is "db" not "mycouchbasedb". The name of the database in Sync Gateway is the key in the "databases" dictionary.

borrrden
  • 33,256
  • 8
  • 74
  • 109
0

Thank to @borrrden , I got it working with the following config:

{
    "log":["CRUD+", "REST+", "Changes+", "Attach+"],
    "interface":":4984","adminInterface":":4985",
    "databases": {
        "mycouchbasedb": {
            "server":"http://127.0.0.1:8091",
            "sync":`
                function (doc) {
                    channel (doc.channels);
                }
            `,
            "username":"Administrator",
            "password":"123456",
            "users": {
                "GUEST": {
                    "disabled": true,
                    "admin_channels": ["public"]
                },
                "myacc":{
                    "password":"123456"
                }
            },
            "enable_shared_bucket_access":true,
            "import_docs":"continuous"
        }
    }
}

Administrator is the user account of Couchbase server and myacc is the user that I created in Security section. but I don't know what this function does and what is other variants of it:

        "sync":`
            function (doc) {
                channel (doc.channels);
            }
Mdeh
  • 451
  • 4
  • 8
  • Regarding the last part about "sync". That's the Sync Gateway sync function. It's key to how Sync Gateway works. You can read about it in the Couchbase documentation. – Hod Feb 24 '18 at 09:49