具有多个客户端的Web应用程序数据库 [英] Database for web app with multiple clients

查看:100
本文介绍了具有多个客户端的Web应用程序数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在现实世界的Web应用程序中,如何为多个客户/公司/客户存储数据?

In a real-world web app, how does one go about storing data for multiple clients/companies/customers?

假设我们为一个客户拥有以下集合:

Lets assume we have the following collections for one client:

- users
- tasks

我如何将该系统扩展到第二个客户端?有没有标准的方法?

How would I extent this system to a second client? Is there a standard approach?

注意:我正在使用Firestore(无SQL).

Note: I am using Firestore (no-sql).

推荐答案

我们为每个客户端使用一组单独的集合.我们的数据结构对我们来说真的很好,看起来像这样……

We use a separate set of collections for each client. Our data structure works really well for us and looks like this...

/clients/{clientId}/reportingData
/clients/{clientId}/billingData
/clients/{clientId}/privateData

使用安全规则,我们允许客户读取其reportData和billingData集合,但不能读取privateData集合.

Using security rules, we allow clients to read their reportingData and billingData collections, but not the privateData collection.

但是,如果您需要同时在多个客户端之间查询数据(例如,供内部使用),那么Frank的选项1会更好,并带有clientId字段.

However, if you need to query data across multiple clients at the same time (for internal use, for example), then Frank's option 1 would work better, with a clientId field.

我们与用户做同样的事情...

We do the same thing with users...

/users/{uid}/publicProfile(任何人都可以阅读,只有用户可以写)

/users/{uid}/publicProfile (anyone can read this, only the user can write)

/users/{uid}/userProfile(仅用户可以读写)

/users/{uid}/privateProfile(用户无法读取或写入的内部数据)

/users/{uid}/privateProfile (internal data that the user can't read or write)

这篇关于具有多个客户端的Web应用程序数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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