如何压缩 PouchDB 中的视图

How to compact views in PouchDB

CouchDB 提供了三个与压缩相关的 API 端点:

  1. /{db}/_compact 压缩磁盘上的数据。
  2. /{db}/_compact/{ddoc} 压缩视图
  3. /{db}/_view_cleanup 清理过时的视图。

PouchDB 为第一个提供了类似的功能。

  1. compact() 压缩磁盘数据

但其他两个从文档中不清楚。 viewCleanup() 似乎对应于 /{db}/_view_cleanup,其描述为:

Cleans up any stale map/reduce indexes.

As design docs are deleted or modified, their associated index files (in CouchDB) or companion databases (in local PouchDBs) continue to take up space on disk. viewCleanup() removes these unnecessary index files.

See the CouchDB documentation on view cleanup for details.

但是,描述中的 link 描述了视图压缩(紧接着讨论了视图清理)。

那么 实际上 如何压缩 PouchDB 中的视图?

来自source code in pocuhdb-mapreduce.js, it looks like viewCleanup just removes unused view locally and also on remote CouchDB servers. There is no equivalent of a view compaction, because it's not necessary locally – see Nolan's answer on Github.