I have some documents in couchdb that have fields that are id arrays for different related documents:
{ associatedAssets: ["4c67f6241f4a0efb7dc2abc24a004dfe", "270fd4508a1222a1e2a27cbe7f002d9z"] }
I would like to write a view that allows me to pass a key, which itself is an array of identifiers, and then return documents whose associated Assets fields contain one or more identifiers that passed through the key array, for example
$.ajax({ url: "/db/_design/design_doc/_view/summaryByAssociatedAssets", type: "post", data: JSON.stringify({keys: ["4c67f6241f4a0efb7dc2abc24a004dfe", "6c67f6241f4a0efb7dc2abc24a004dfd"]}), dataType: "json", contentType: "application/json", }) .done(function(resp){ console.log(resp[0]); });
will return documents for which the associated asset array contains one or more keys "4c67f6241f4a0efb7dc2abc24a004dfe", "6c67f6241f4a0efb7dc2abc24a004dfd".
I cannot access the keys in my view, so I'm not sure if I can do this? Is there a better way to do this?
Thanks!
source share