SQL 查询我想在 Pouchdb 中实现的目标

SQL query'ish for what I want to achieve in Pouchdb

SELECT * FROM smo_images
WHERE search_term in search_helpers (search helpers is array or keywords)
OR search_term = smo_code
OR search_term = size
OR search_term = category;

我想在 PouchDB 中实现类似上面的东西。我是 nosql 和 PouchDB 的新手。该文档令人困惑且不简单。

对我来说,the documentation 非常清晰明了。它提到了 SQL:

的老派方法

Indexes in SQL databases

Quick refresher on how indexes work: in relational databases like MySQL and PostgreSQL, you can usually query whatever field you want:

SELECT * FROM pokemon WHERE name = 'Pikachu';

But if you don't want your performance to be terrible, you first add an index:

ALTER TABLE pokemon ADD INDEX myIndex ON (name);

The job of the index is to ensure the field is stored in a B-tree within the database, so your queries run in O(log(n)) time instead of O(n) time.

从那里开始与 NoSQL:

进行比较

Indexes in NoSQL databases

All of the above is also true in document stores like CouchDB and MongoDB, but conceptually it's a little different. By default, documents are assumed to be schemaless blobs with one primary key (called _id in both Mongo and Couch), and any other keys need to be specified separately. The concepts are largely the same; it's mostly just the vocabulary that's different.

In CouchDB, queries are called map/reduce functions. This is because, like most NoSQL databases, CouchDB is designed to scale well across multiple computers, and to perform efficient query operations in parallel. Basically, the idea is that you divide your query into a map function and a reduce function, each of which may be executed in parallel in a multi-node cluster.

接下来是关于 Map/Reduce 函数、temporary/persistent 视图等的描述和示例代码。