简体   繁体   English

CouchDB:单独的集合

[英]CouchDB: separate collections

A quick thought today, does CouchDB handle multiple collections of databases? 如今,CouchDB是否可以处理多个数据库集合?

To explain what I mean, our web app has two types of users, free and commercial which differ greatly in their document and view structure. 为了解释我的意思,我们的Web应用程序有两种类型的用户,免费和商业用户,其文档和视图结构差异很大。 For all intents and purposes, they are completely different products. 出于所有目的和目的,它们是完全不同的产品。 A database is created per customer, and contains all their particular data and settings. 将为每个客户创建一个数据库,其中包含其所有特定数据和设置。

Without going into too much needless info, we currently have a mix of commercial-based databases and free-based databases mixed together in one instance of CouchDB. 在不涉及过多不必要信息的情况下,我们目前在一个CouchDB实例中将基于商业的数据库和基于免费的数据库混合在一起。 From a purely organisational standpoint, it's quite messy to sift through the (currently 50) free-based databases to find the (currently 3) commercial-based databases. 从纯粹的组织角度来看,筛查(目前有50个)基于免费的数据库以找到(目前有3个)基于商业的数据库是很麻烦的。 Is there a better way to organise or sort these? 有没有更好的方法来组织或分类这些?

Has anyone got any ideas? 有没有人有什么想法? I know I could simply add prefixes to the databases, but was after a MySQL-type approach where creating a separate database would be possible. 我知道我可以简单地在数据库中添加前缀,但是在使用MySQL类型的方法之后,可以创建一个单独的数据库。

Other than grouping your data by using a property of each document (ie you put all of your free customers in the same db and prefix your views with that property) I don't think there's any way of grouping similar databases together aside from your suggestion of a prefix. 除了通过使用每个文档的属性将数据分组(即,将所有免费客户放在同一个数据库中并为该属性添加视图前缀)之外,除了您的建议外,我认为没有任何方法可以将相似的数据库分组在一起前缀

You could always consider running two instances, one for the free users and one for the paid ones. 您始终可以考虑运行两个实例,一个用于免费用户,一个用于付费用户。

为什么不向沙发床用户文档中再添加2个属性(如.instance和.type),您可以将它们存储在.type字段“ FreeUserType”或“ PaidUserType”中,而在.instance字段中只写一些“ ID”这样,您可以以非常复杂的方式查询用户群,这将为您提供更多的灵活性,使您可以使用更多“相关”数据对象扩展数据库,从而可以“加入”查询。

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

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