如何在CouchDB中按id字段过滤视图?

时间:2017-09-28 12:09:07

标签: couchdb

我有一个输出以下JSON的视图:

{"total_rows":26,"offset":0,"rows":[
{"id":"SIP-13","key":[1506146852518,"SIP-13"],"value":{"clientId":"CLIENT-2","orderCount":2}},
{"id":"SIP-12","key":[1506147024308,"SIP-12"],"value":{"orderCount":1}},
{"id":"SIP-14","key":[1506159901457,"SIP-14"],"value":{"orderCount":1}},
{"id":"SIP-15","key":[1506161053712,"SIP-15"],"value":{"clientId":"CLIENT-2","orderCount":2}},
{"id":"SIP-16","key":[1506448298050,"SIP-16"],"value":{"clientId":"CLIENT-3","orderCount":1}}
]}

...我想在这里找到id: "SIP-15"行。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您必须使用复杂的密钥。索引的第一个字段可以是任何内容,第二个字段必须是SIP-15。

查询:

  

startkey =?[NULL," SIP-15"&安培; endkey = [{}," SIP-15"]