Couchbase 同步网关客户端和服务器端
Couchbase Sync Gateway Client and Server Side
我正在开始一个项目,在阅读了大量内容后我得出的结论是我应该使用来自移动和服务器(后端)应用程序的同步网关 REST API 调用,而不是存储桶阴影。但是,Sync Gateway 在进行查询时显然很烦人,尤其是动态查询。我的想法是为后端应用程序编写一个小模块,它将使用 Sync Gateway 进行写入,使用 NodeJS SDK 进行读取。这样我就可以为 gets/queries 使用 N1QL、视图等(而不是使用 Sync Gateway 做一些尴尬的事情)并且我可以确保我的数据在写入时正确同步。
是不是我的思路有问题?任何人都可以预见这种方法的任何问题吗?
NodeJS SDK 无法访问 Sync Gateway 存储桶,除非使用存储桶阴影,不推荐这样做。
如果您不想使用 Couchbase 移动版,请不要使用 Sync Gateway,在服务器端利用 Couchbase 服务器和 NodeJS SDK,并为移动版创建您自己的 REST API。
没有什么能阻止您使用 NodeJS SDK 直接连接到同步网关存储桶。但是,存储桶的 JSON 内容没有公开记录,并且在未来的版本中可能会发生变化。
2014 年 6 月的这个论坛帖子默认这种方法是可行的,风险自负:https://groups.google.com/forum/#!topic/mobile-couchbase/OeTk1fzYJvE
I think the main pattern for interacting with Sync Gateway is for server code to subscribe to channels, and occasionally mutate documents based on the changes it sees. If an occasional map reduce query comes up, in my opinion it's fine to run those against the gateway bucket, and avoid the overhead of bucket shadowing completely. As long as you understand that the Sync Gateway data layout could change in the future. We don't consider the JSON we store in Couchbase Server to be a public API.
Right now you'd want to wrap your map functions like this:
function(doc, meta) {
if (doc._sync && !doc._deleted) {
emit(doc.foo, null);
}
}
方法是使用过滤器定义您的视图以排除同步网关文档。但是,上面的警告仍然适用:同步网关可能会更改它在未来版本中表示文档的方式。
我还找到了另一个 SO 答案,其中详细介绍了同步网关存储桶上的 N1QL 查询:
我正在开始一个项目,在阅读了大量内容后我得出的结论是我应该使用来自移动和服务器(后端)应用程序的同步网关 REST API 调用,而不是存储桶阴影。但是,Sync Gateway 在进行查询时显然很烦人,尤其是动态查询。我的想法是为后端应用程序编写一个小模块,它将使用 Sync Gateway 进行写入,使用 NodeJS SDK 进行读取。这样我就可以为 gets/queries 使用 N1QL、视图等(而不是使用 Sync Gateway 做一些尴尬的事情)并且我可以确保我的数据在写入时正确同步。
是不是我的思路有问题?任何人都可以预见这种方法的任何问题吗?
NodeJS SDK 无法访问 Sync Gateway 存储桶,除非使用存储桶阴影,不推荐这样做。
如果您不想使用 Couchbase 移动版,请不要使用 Sync Gateway,在服务器端利用 Couchbase 服务器和 NodeJS SDK,并为移动版创建您自己的 REST API。
没有什么能阻止您使用 NodeJS SDK 直接连接到同步网关存储桶。但是,存储桶的 JSON 内容没有公开记录,并且在未来的版本中可能会发生变化。
2014 年 6 月的这个论坛帖子默认这种方法是可行的,风险自负:https://groups.google.com/forum/#!topic/mobile-couchbase/OeTk1fzYJvE
I think the main pattern for interacting with Sync Gateway is for server code to subscribe to channels, and occasionally mutate documents based on the changes it sees. If an occasional map reduce query comes up, in my opinion it's fine to run those against the gateway bucket, and avoid the overhead of bucket shadowing completely. As long as you understand that the Sync Gateway data layout could change in the future. We don't consider the JSON we store in Couchbase Server to be a public API.
Right now you'd want to wrap your map functions like this:
function(doc, meta) { if (doc._sync && !doc._deleted) { emit(doc.foo, null); } }
方法是使用过滤器定义您的视图以排除同步网关文档。但是,上面的警告仍然适用:同步网关可能会更改它在未来版本中表示文档的方式。
我还找到了另一个 SO 答案,其中详细介绍了同步网关存储桶上的 N1QL 查询: