Mongoose use $and to apply same attribute two filters Mongoose use $and to apply same attribute two filters mongoose mongoose

Mongoose use $and to apply same attribute two filters


  • use $or instead of $and, because it would satisfy one of condition
  • remove pending status from $in condition
  • $and to wrap package condition and $or conditions
filter = {  $and: [    { package: { $in: ids } },    {      $or: [        { status: { $in: ["accepted", "charged", "captured"] } },        {          status: "pending",          date: { $lt: current_time }        }      ]    }  ]};

Playground