Reputation: 5868
I know how to use find
to find when there is array field or nested objects inside documents.
But Is it possible to find inside a found mongoose object? like this:
let result = await model.findOne({});
if (result){
let findInsideFound=await result.findOne({arrayField:'xxx'}) // i need both variables. ( first result, and findInsideFound both )
or It is impossible and have to use Array.find
or etc in result.toJSON()
?
Upvotes: 0
Views: 65
Reputation: 2358
If I get your point correctly, you want to find in the collection and then find again inside that result array of documents. Short answer is no, the result is just some documents and it doesn't represent the collection itself. When the query is done and you get your result from your query, it gets out of mongodb and you have your result here in nodes.
Upvotes: 1