I have a collection with a (multi-level) nested array like this:
{ _id: "1", metadata: { parent: { tags: ['foo', 'bar'] } } }
{ _id: "2", metadata: { parent: { tags: ['foo'] } } }
{ _id: "3", metadata: { parent: { tags: ['bar'] } } }
I would like to query records matching parent's tags containing keywords like foo
:
{ _id: "1", metadata: { parent: { tags: ['foo', 'bar'] } } }
{ _id: "2", metadata: { parent: { tags: ['foo'] } } }
How to write MongoDB query?