简体   繁体   English

Couchbase nodejs如何从同步网关桶检索数据到服务器桶

[英]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. 所以我在我的机器上本地运行的couchserver上有这个config.json

{
    "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. 而这个syncgw-config.json作为同步网关设置。

{
    "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. 好消息是我可以将数据插入到我的restful-sample存储桶中,并使用上述同步网关设置将其同步或“隐藏”到我的移动设备上。 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. 坏消息是,反之亦然,当我从移动应用程序添加数据时,这些数据没有自动同步到restful-sample存储桶,但这些数据正在成功插入同步网关存储桶。 Am I missing some config? 我错过了一些配置吗? I gotta be honest here, I dont think couchbase's documentations are that clear. 我在这里说实话,我不认为couchbase的文件很清楚。

BTW I followed this fine cean-stack tutorial in case you wanna see the actual queries happening on the server. 顺便说一下,我想按照这个精美的cean-stack教程 ,以防你想看到服务器上发生的实际查询。

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 . 从服务器访问Sync Gateway数据的推荐方法是利用Sync Gateway REST API With this API you can perform CRUD operations or access view . 使用此API,您可以执行CRUD操作或访问视图 It's much less convenient than accessing Couchbase server with an SDK I agree, and a lot of feature are mising (N1QL for example). 它比使用我同意的SDK访问Couchbase服务器要方便得多,并且很多功能都很明显(例如N1QL)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM