0
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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Do you know if just key: ['Hearts', 'Clubs'] works? Why the startKey and endKey?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.