我的数据库中的文件如下:
_id 999A
properties {cust_id:1234,
loc_id:ABC}
_id 999B
properties {cust_id:1234,
loc_id:ABD}
_id 999C
properties {cust_id:1235,
loc_id:ABD}
_id 999D
properties {cust_id:1235,
loc_id:ABE}
我需要获得访问两个特定诊所(例如ABC和ABD)的客户的数量和ID。我的查询应该是什么样的?
答案 0 :(得分:0)
创建视图'by_location'
//map function content
function(doc) {
emit(doc.properties.loc_id, doc.properties.cust_id);
}
//reduce function
_count
现在无需减少查询即可获得每次访客:http://localhost:5984/clinic/_design/visits/_view/by_location?key="ABC"&reduce=false
http://localhost:5984/clinic/_design/visits/_view/by_location?key="ABC"