principiorum
principiorum

Reputation: 616

How to filter data of type specified in array in mongoDB?

i try to filter my mongo database to get data that types included in array, adn filter certain type further. my filter is like this

db.event.find({
  $or: [{ date: { $lte: new Date().toISOString() } }, { status: 'DONE' }],
  type: { $in: ['PUBLIC', 'TEAM', 'PRIVATE'] },
  team: ObjectId("512e28984815cbfcb21646a7")
})

with those filter i aimed to get event that was ended, which type is all mentioned in array, and for TEAM type, it will search only event that has team id specified. But using that filter i get nothing, anyone know how to achieve my intention?

Upvotes: 0

Views: 111

Answers (1)

husanu
husanu

Reputation: 304

put the expressions in $and operator like in the eg

Upvotes: 1

Related Questions