我想通过一个值过滤文档,该值包含返回我制作的设计视图的键字段中的数组。
// _design/products/_view/all
function(doc) {
if (doc.type && doc.type == 'producto'){
emit([doc.created, doc.user], doc);
}
}
结果:
{"total_rows":3,"offset":0,"rows":[ {"id":"64243f77b5135758d1f0d55c250001f5","key":[1364931254000,"samuelb1311"],"value":{"_id":"64243f77b5135758d1f0d55c250001f5","_rev":"3-50f67780d6388f3aad469dbdd1081b9e","nombre":"limon ","precio":250,"user":"samuelb1311","created":1364931254000,"type":"producto"}}, {"id":"64243f77b5135758d1f0d55c2500058e","key":[1364931381000,"samuel123"],"value":{"_id":"64243f77b5135758d1f0d55c2500058e","_rev":"3-c1f893af011ee5a3687b0a9eeedc3467","nombre":"lima ","precio":360,"user":"samuel123","created":1364931381000,"type":"producto"}}, {"id":"64243f77b5135758d1f0d55c25000e7a","key":[1364931447000,"samuelb1311"],"value":{"_id":"64243f77b5135758d1f0d55c25000e7a","_rev":"3-2b05730dfcf3407b7335ec029e5cfdc5","nombre":"naranja ","precio":25,"user":"samuelb1311","created":1364931447000,"type":"producto"}} ]}
我需要键中的日期来按从第一个插入到最后一个插入的升序和降序对信息进行排序,反之亦然。
那么,如何按用户过滤信息,例如用户“samuelb1311”或用户“samuel123”?
我尝试了 startkey 和 endkey 之类的东西,但这对我不起作用,那是返回空响应。
谢谢你能给我带来的一些信息!