Mongo db query all documents contains substring matching in a given array of strings

Viewed 173

The title might be a little confusing, here is the data:

location_collection:

{name: "A"}
{name: "A1"}
{name: "B"}
{name: "B1"}
{name: "C"}
{name: "C1"}

my query:

 mongooseModel.find({ name: { $in: ['A', 'B'] } })

what I get:

{name: "A"}
{name: "B"}

What I want to get:

{name: "A"}
{name: "A1"}
{name: "B"}
{name: "B1"}

I try this but it doesnt work:

 mongooseModel.find({ name: { $in: [$substr:['A'], $substr:['B']] } })

Thanks in advance.

1 Answers
Related