我需要获取所有文件,例如“_id”字段等于另一个文档字段,例如“APPID”
{
"_id": "xxxx-xxxx-xxxx-xxxx",
"_rev": "xxxx-xxxx-xxxx-xxxx",
"header": {
"appId": "xxxx-xxxx-xxxx-xxxx"
那么查询是什么?
"selector": {
"_id": {
"$eq": header.appId
}
},
你不能用Mango做“子查询”。
从我看到的,你正试图获得appId列出的所有文件。
这可以通过使用视图来完成。
您的地图功能如下:
if(doc.header && doc.header.appId){
emit(doc.doc.header.appId,{_id: doc.header.appId});
}
结果将是doc.header.appId
映射的文档列表。
如果使用?include_docs=true
查询视图,则文档将连接到响应,因为我们正在进行ManyToJoin连接。