基于JSON的数据库的理想复制过滤器像Couchbase,CouchbaseLite,CouchDB等? [英] Ideal Replication Filter for JSON based Databases Like Couchbase, CouchbaseLite, CouchDB, etc.?

查看:553
本文介绍了基于JSON的数据库的理想复制过滤器像Couchbase,CouchbaseLite,CouchDB等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在 CouchDB 服务器端上编写过滤器函数来过滤特定于用户的文档。此过滤器将仅允许特定用户可访问的少数选定文档,而不是整个大小TB数据库的复制。



在这里,我发现了一个类似的问题 CouchDB:限制用户仅复制自己的文档,但它

ol>
  • 什么是最好的方法来指定这样的过滤器?

  • 我应该如何编写这样的过滤器函数,任何书面示例?

  • 我应该在每个文档中包含什么,这样:



    在社交网络的上下文中,假设您要从服务器获取用户数据,如图片,在这种情况下,包含图片的文档将在其中保存 userId 。但有时可能是这样的情况,当这个人的朋友将访问他的个人资料,然后他们也将能够查看这些照片。在这种情况下,无论朋友访问他的个人资料,图片文档都将复制到朋友,他也可以查看这些图片。


  • 如何完成此类过滤?



    更多信息:移动平台端我使用CouchbaseLite和在服务器端我使用CouchDB。我只想在移动平台上过滤文档。


    解决方案

    CouchDB过滤器功能只能访问单个文档过滤,因此您不能使用其他文档中的任何信息。



    基本上,你会有一个类似于联接的方法,比如从照片发布文档中解除引用到所有者的文档,查找所有者的朋友列表。在每个文档中包含一个属性,列出应该获取它的确切用户组。



    此外,请注意,这不提供任何类型的访问控制。没有办法选择性地拒绝对CouchDB中文档的读取访问,因此您无法阻止用户查看陌生人的相册。为了做到这一点,你必须使用基于数据库的用户方法,它有自己的缺点 - 你最终必须在数据库之间设置大量的复制,以在它们之间共享文档,这不能很好地扩展。



    查看Couchbase同步网关( https:// github。 com / couchbase / sync_gateway ) - 它与CouchDB的复制兼容,但添加了启用这种选择性同步和访问控制的功能。它应该绝对可行的实现社会网络;这是我们在设计时考虑的用例之一。 (我是项目的首席工程师。)


    I am about to write a filter function on CouchDB server side to filter documents specific to the user. This filter will allow replication only for those few selected documents that a particular user has access to rather than whole database of TBs of size.

    Here I found a similar question CouchDB: Restricting users to only replicating their own documents but it does not provide me the info that I need.

    SO my questions remain:

    1. What can be the best approach to specify such a filter?
    2. How should I write such a filter function, any written example?
    3. What should I include in every doc so that filter will work this way:

      In the context of a social network, suppose you want to fetch user data like pictures from the server, in this case a document that is containing pictures will be holding userId in it. But sometimes it can be the case when friends of this person will visit his profile and then they will also be able to view those photos. In that case whenever a friend visits his profile then Picture doc will be replicated to the friend and he will be able to view those pictures also.

    How can I accomplish such a filter?

    More Info: On the Mobile platform side I am using CouchbaseLite and on the server side I am using CouchDB. I want only filtered documents on Mobile platform.

    解决方案

    A CouchDB filter function only has access to the single document being filtered, so you can't use any information from other documents. This rules out "join-like" approaches, like dereferencing from a photo-post doc to the owner doc to look up the owner's list of friends.

    Basically you would have to include a property in every document that lists the exact set of users who should get it.

    Also, note that this doesn't provide any sort of access control. There is no way to selectively deny read access to documents in CouchDB, so you can't prevent a user from viewing a stranger's photo albums. To do that you'd have to go with the database-per-user approach, which has its own drawbacks — you end up having to set up a lot of replications between the databases to share documents between them, which doesn't scale well.

    Take a look at at the Couchbase Sync Gateway (https://github.com/couchbase/sync_gateway) -- it's replication-compatible with CouchDB but adds features that enable exactly this kind of selective sync and access control. It should definitely be feasible to implement a social network with it; that's one of the use cases we had in mind when we designed it. (I'm the lead engineer on the project.)

    这篇关于基于JSON的数据库的理想复制过滤器像Couchbase,CouchbaseLite,CouchDB等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆