4

I want to be able to search my documents for every item that either doesn't have the item hidden in it, or if it does, only grab it if it's not equal to true. Is this possible?

I have the following selection and I am getting a bad query error.

selector: {
  hidden: {$in: [null, false]}
}

For example:

I want these to be returned

{_id: "1", hidden: false, name: "John" }
{_id: "2", name: "Jim" }

This not to be returned

{_id: "3", hidden: true, name: "James" }
bryan
  • 8,879
  • 18
  • 83
  • 166

1 Answers1

6

You can try with an or expression that checks the existence of the 'hidden' attribute

 {
  "selector": {
    "$or": [
      {
        "hidden": false
      },
      {
        "hidden": {
          "$exists": false
        }
      }
    ]
  }
}
Juanjo Rodriguez
  • 2,103
  • 8
  • 19