How to use mongoose find to filter by inner arrays

You only need "extra_fields.tag": "alias" to compare the field and the result.

The query is quite simple:

db.collection.find({
  "extra_fields.tag": "alias"
})

In this way, every document with, at least, one ‘tag’ field with value ‘alias’ will be returned.

Example here

Edit:

To find by multiple fields you can use this:

db.collection.find({
  "extra_fields.linked_collection_id": "abc",
  "extra_fields.linked_master_id": "xyz"
})

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top