Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我在 couchdb 中有具有以下 ID (1,2,3,4,...,n) 的文档,我只想检索三个 ID (2,4,7)。
我是否必须查询它们中的每一个,或者我可以将带有 ids ([2,4,7]) 的数组传递给视图吗?
您可以通过向数据库的端点发出POST请求来获取具有给定 ID 列表的所有文档。_all_docs请求正文是一个 JSON 文档,其中包含一个名为 的字段keys,其中包含一组文档 ID。如果您想要完整的文档(而不仅仅是它们的 ID 和修订版),您还必须include_docs=true作为查询参数提供。这是 curl 的示例:
POST
_all_docs
keys
include_docs=true
curl https://example.com/db/_all_docs?include_docs=true -X POST -d ' { "keys": ["2", "4", "7"] }'