Okay, so my problem is that I have a multikey view, that works.
function (docu) {
if(!docu.deleted){
emit([docu.key1, docu.key2, docu.key3], docu);
}
}
I am attempting to add another key to this already multi-key array. The key I am attempting to add is an array of string values,
[
"test",
"test2"
]
I am querying my view using PouchDB
and its built in query method, code is below.
database.query("views/viewTest", {
startkey: [key1, key2, key3, key4],
endkey: [key1, key2, key3, key4],
reduce: false
}, function (err, res) {
if (err) {
console.log(err);
alert(err);
} else {
console.log(res);
}
});
Where key4
is my new array. I have a little luck with my map function by changing it to emit([docu.key1, docu.key2, docu.key3, [docu.key4]], docu);
but this only works if there is only one item in the array, and I need it to work for multiple items in the array.
I can't figure out how to set up my view or query to utilize multiple items in my key4
array.
I have tried querying with startkey
and endkey
, where key4
had an {}
pushed into it for the endkey
, but this returned everything. I only want the values returned within the key4
array, as long as they match the other keys as well.
So to sum:
- My view/query works before I add in the new key4 array.
- The view/query works if the key4 array has ONE item in it.
- I need it to work for ALL items in the key4 array.
- I have tried multiple things and can/could not get this to work.
Any suggestions?