in NodeJS with Mongoose, how do i search something in an array using findOne()
? I want to search stuff like 626ead978edc5f2a3f7ca924
in the users
array in my sessionCollection
-Model.
My DB looks like this: Database Picture
CodePudding user response:
It'll work normally as it does for non array key:
SessionCollection.findOne({users: "626ead978edc5f2a3f7ca924"})
CodePudding user response:
I coudn't understand your question, but I hope this can help you This code work for get the element's id in an array
https://www.codegrepper.com/code-examples/javascript/how to find id in array javascript