Mongo newbie here ππ» Is it possible to do findOne after the populate?
The query string I have available belongs to the referenced document. I would like to first populate it and then find the document I am looking for.
Other wise I first need to do a findOne in one collection and pass the result to another collectionβs findOne.
I am trying to avoid an unnecessary findOne operation but maybe I am overthinking it and its okay to do multiple findOneβs to reach a result?
Another solution comes to my mind is to make the query string I have available an indexed unique field so I can directly do findOne.
Great point you made there. I never tried that, but I guess you can give it try. For cases like these, I tend to use aggregation.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Mongo newbie here ππ»
Is it possible to do findOne after the populate?
The query string I have available belongs to the referenced document. I would like to first populate it and then find the document I am looking for.
Other wise I first need to do a findOne in one collection and pass the result to another collectionβs findOne.
I am trying to avoid an unnecessary findOne operation but maybe I am overthinking it and its okay to do multiple findOneβs to reach a result?
Another solution comes to my mind is to make the query string I have available an indexed unique field so I can directly do findOne.
Great point you made there. I never tried that, but I guess you can give it try. For cases like these, I tend to use aggregation.