如何选择在其他ID字段筛选的couchbase中的文档?

问题描述 投票:0回答:1

我有一个存储桶中的架构文档:

{
  "status": "done",
  "id": 1
}

我想选择所有将status作为done的文档。

couchbase n1ql
1个回答
2
投票

假设您使用的是Couchbase Server 4.x或更高版本,则可以使用N1QL查询来执行此操作。例如:

SELECT d.*
FROM mydocuments d
WHERE d.status == 'done'

您还需要在status上创建索引(至少 - 创建索引比StackOverflow答案可以提供的更复杂),如下所示:

CREATE INDEX ix_status ON mydocuments (status);

有关更多信息,请查看N1QL documentationinteractive N1QL tutorial

© www.soinside.com 2019 - 2024. All rights reserved.