new in mongoose here, I have a mongoose model that has property which is an array of ids, so I want to retreive a specific id in that array. My code is something like this:
async (idToRetreive, contextUserId) => {
const retreivetodoId = await UserModel.findOne({ _id: contextUserId })
.select('todos -_id')
.where('todos')
.equals(idToRetreive);
//todos is an array of ids
const retreiveTodoObject = await TodoModel.findOne({ _id: retreivetodoId });
return retreiveTodoObject;
}
but I have no success. help?