Reputation: 8849
alice.view('characters', 'soldiers', {
'keys': ['Hearts', 'Clubs']
}, function(err, body) {
if (!err) {
body.rows.forEach(function(doc) {
console.log(doc.value);
});
}
});
Does this filter on key: "Heart"
or key: "Clubs"
or the exact match key: ["Hearts", "Clubs"]
? I wish to do the latter where my keys are arrays with 2 items.
Also if I JUST inserted into the db, can I expect this view to immediately be up to date when I run that code?
Upvotes: 0
Views: 310
Reputation: 706
the view()
function above will filter on key: "Heart" or key: "Clubs".
instead, you may want to try using the startkey
and endkey
:
*DB_NAME*/_design/characters/_view/soldiers?startkey=["Hearts", "Clubs"]&endkey=["Hearts", "Clubs"]&inclusive_end=true
something, like this:
alice.view('characters', 'soldiers', {
'startkey': ['Hearts', 'Clubs'],
'endkey': ['Hearts', 'Clubs'],
'inclusive_end': true
}, function(err, body) {
if (!err) {
body.rows.forEach(function(doc) {
console.log(doc.value);
});
}
})
reference:
https://stackoverflow.com/a/42398481
Upvotes: 1