0

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()?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.