0

Suppose I have the following item structure:

"_id": "12325523623453254",
  "blas": {
    "blaA": 0,
    "blaB": 0,
    "blaC": 0,
    "blaD": 1,
  }
}

I like to find the items with "blas" including at least one non zero value.

Rahul
  • 15,979
  • 4
  • 42
  • 63
erogol
  • 13,156
  • 33
  • 101
  • 155

1 Answers1

0

You can do this with an $or query that uses dot notation in the keys to access the fields within blas:

db.test.find({$or: [
    {'blas.blaA': {$ne: 0}},
    {'blas.blaB': {$ne: 0}},
    {'blas.blaC': {$ne: 0}},
    {'blas.blaD': {$ne: 0}}
]})
JohnnyHK
  • 305,182
  • 66
  • 621
  • 471