每个用户数据库(pouchdb / couchdb)&共享数据-可行吗? [英] per user db (pouchdb/couchdb) & shared data - doable?

查看:86
本文介绍了每个用户数据库(pouchdb / couchdb)&共享数据-可行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下用例/应用程序:

I have the following use case / application:

一个TODO应用程序,用户可以在其中使用:对TODO进行CRUD(我使用的是pouchdb / couchdb同步)。几乎基于Josh Morony的教程

a TODO app where users can: CRUD their on TODOs (I am using pouchdb/couchdb syncing). Pretty much based on Josh Morony's tutorial

现在,我想添加用户的功能来共享(仅发布,没有编辑 /放置)其待办事项

Now I want to add ability of users to "share" (post only, there is no "edit"/put) their TODO items with other users, who would be able to just view (read) those (no write access etc).

我正在考虑添加一个单独的数据库(我们称其为共享的TODOs DB),我的服务器可以在其中写入并且所有用户只能读取。
因此,任何用户都可以在只读数据库上执行.find(),而在该数据库中发布时,仍然应由服务器根据用户共享其TODO的请求进行管理。

I was thinking about adding a separate DB (let's call it "shared TODOs DB") where my server can write and all users can only read. So any user could potentially do .find() across that read only db, while posting in there will still be governed by a server upon requests to share their TODO coming from users.

是否存在已知的模式(方法)?

推荐答案

因此,对于此类项目,请按照以下步骤操作:用户数据库是数据库的推荐模式。

So for this kind of project, per-user database is the recommended pattern for your databases.

因此,基本上,您将拥有:

So basically, you will have :


  • 每个用户一个私有数据库(具有写/读权限)

  • 一个中央数据库只读

对于中央数据库,您需要将其设为只读,并且还只允许共享文档。为此,您需要某种应用程序代理。您基本上可以在中央数据库的顶部构建API,并仅允许访问共享文档。

As for the central database, you need it to be read-only and you also need to allow shared documents only. You need some kind of application proxy for this. You can basically build an API on top of the central database and allow access to shared documents only.

然后,您可以设置从每个用户数据库到中央数据库的复制,并将复制保留在_replicator数据库中。

Then, you can setup replications from each user database to the central database and persist de replication in the _replicator database.

我不确定每个用户的数据库插件当前是否在版本2.XX下都可以使用,但是您可以自己进行某种形式的操作应用程序过程(创建用户,然后创建数据库,然后管理新数据库的权限)

I'm not sure that per-user database plugin is working at the moment with the version 2.X.X but you can do it yourself with some sort of application process (Create the user, then create the database, then manage permissions of the new database)

这篇关于每个用户数据库(pouchdb / couchdb)&共享数据-可行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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