PouchDB 结构 [英] PouchDB structure

查看:17
本文介绍了PouchDB 结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 nosql 概念的新手,所以当我开始学习 PouchDB,我找到了这个转换表.我的困惑是,如果说我有多个表,PouchDB 如何处理,这是否意味着我需要创建多个数据库?因为根据我在pouchdb中的理解,一个数据库可以存储很多文档,但是一个文档意味着sql中的一行还是我误解了?

i am new with nosql concept, so when i start to learn PouchDB, i found this conversion chart. My confusion is, how PouchDB handle if lets say i have multiple table, does it mean that i need to create multiple databases? Because from my understanding in pouchdb a database can store a lot of documents, but a document mean a row in sql or am i misunderstood?

推荐答案

... 这是否意味着我需要创建多个数据库?

... does it mean that i need to create multiple databases?

没有.

...一个文档意味着sql中的一行还是我误解了?

... a document mean a row in sql or am i misunderstood?

没错.SQL 表定义了列标题(名称和类型)——它们是文档的 JSON 属性名称.

That's right. The SQL table defines column header (name and type) - that are the JSON property names of the doc.

因此,所有具有相同属性的文档(行)(所谓的模式")都等同于您的 SQL 表.您可以根据需要在一个数据库中拥有尽可能多的不同模式(访问 json-schema.org 以获得一些灵感).

So, all docs (rows) with the same properties (a so called "schema") are the equivalent of your SQL table. You can have as much different schemata in one database as you want (visit json-schema.org for some inspiration).

如何单独申请?创建 CouchDB 视图!您可以通过 SQL 中的一个请求获取所有/部分行"表格数据(具有相同架构的文档).

How to request them separately? Create CouchDB views! You can get all/some "rows" of your tabular data (docs with the same schema) with one request as you know it from SQL.

要轻松编写此类视图,属性 type 对于 CouchDB 文档来说非常常见.您在 SQL 表中的已知名称可以是您的类型,例如 doc.type: "animal"

To write such views easily the property type is very common for CouchDB docs. Your known name from a SQL table can be your type like doc.type: "animal"

您的视图名称可能是 animalByNameanimalByWeight.取决于你的需要.

Your view names will be maybe animalByName or animalByWeight. Depends on your needs.

这篇关于PouchDB 结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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