I want to filter documents by a value that contains the array in the key field that returns the design view that I make.
// _design/products/_view/all
function(doc) {
if (doc.type && doc.type == 'producto'){
emit([doc.created, doc.user], doc);
}
}
The result:
{"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"}}
]}
I need the date in the key for sorting the info in order ascending and descending from the first inserted to the last inserted and vice versa.
So, how can I filter the info by an user, for example by the user "samuelb1311" or the user "samuel123" ?
I try things like startkey and endkey, but this not working for me, thats returning empty response.
Thanks for some info you can bring me!