当我使用 user_id(key)、limit(10) 和 skip(0) 参数查询 Couchbase 中的某些视图时,我得到具有以下结构的响应:
{
"total_rows":1896,
"rows":[...]
}
这是我根据 user_id 返回报告列表的观点:-
function map(doc, meta) {
if (doc.type == 'report' && doc.subscribed) {
for (var subscriber in doc.subscribed) {
emit(subscriber, doc);
}
}
}
这是示例报告文档:-
{
"agree_allowed":true,
"assigned_by":"",
"assigned_to":"",
"closed":[
],
"comments_allowed":true,
"details":"Test",
"email":"",
"status":"In Progress",
"subscribed":{
"user_cfd29b81f0263a380507":true,
"user_cfd29b81f0263a380508":true,
"user_cfd29b81f0263a380509":true,
"user_cfd29b81f0263a3805010":true
},
"summary":"Test",
"time_open":0,
"timestamp":"2015-07-17T15:34:30.864Z",
"type":"report",
"user_id":"user_cfd29b81f0263a380507",
"username":"test17"
}
但是行数是 3,所以如果我想实现分页,我怎样才能获得总计数,所以它对分页很有用。