0

enter image description here

I have the following filter which I am trying to test in MongoDB Compass:

{$or: ["OwedTaxes": {$regex: "$"},"OwedTaxes": {$exists: false}]}

Meaning the OwedTaxes field contains a "$" sign or does not exist.

There is a syntax error but I don't understand what it is. What am I doing wrong?

Yong Shun
  • 35,286
  • 4
  • 24
  • 46
user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

2

You need to wrap each element in the array with { } curly brace to represent a valid BSON document.

{
  $or: [
    { "OwedTaxes": {$regex: "$"} },
    { "OwedTaxes": {$exists: false} }
  ]
}
Yong Shun
  • 35,286
  • 4
  • 24
  • 46