I have a mongoose collection that store specific data. and I have an iduser
. that's name : var members = new Schema({iduser : {type : String}})
.
var member = new members({iduser : req.session.user._id})
by the way I have more than one member with the same iduser. and I wanna to find them by index. member.findOne({iduser})[0]
.
I use nodejs for implementation.
CodePudding user response:
Every MongoDb Documents have a ObjectId like "612753311aafd14844ec4933"
so You Can find same IdUser with Object Id
member.findOne({_id : "OBJECT_ID", idUser :req.session.user._id })