Return list of saved items using populate() in Mongoose Return list of saved items using populate() in Mongoose mongoose mongoose

Return list of saved items using populate() in Mongoose


When you do populate, then mongoose will based on the _ids that are stored in savedArticles array go and fetch from the Articles collection documents with those _ids and it will change _ids in savedArticles array with actual documents. So, when your frontend got the result, savedArticles array will be array of objects (documents from Articles collection) and not array of _ids.Now you can iterate over that array and access specific field of each article, like: savedArticles[0].title.