i have a document that store array of strings , i want search by id and by array contain. i used 2 method , both of them return null
the Schema example:
const exampleSchema = new mongoose.Schema{
id : objectId(),
list :Array // will store other id's
}
const Example= mongoose.model("Example", exampleSchema );
// this work
const friend = await Example.findOne({ _id: req.body.friendId }); // return the docuemnt
//this not work - return null
const friend = await Example.findOne({ _id: req.body.friendId, pending: { $in: [req.body.userId] } });
also i tried $elemMatch that not work