Categories
JavaScript Answers

How to do multiple populates with Node Mongoose?

Spread the love

To do multiple populates with Node Mongoose, we call populate multiple times.

For instance, we write

OrderModel.find()
  .populate("user")
  .populate("meal")
  .exec((err, results) => {
    // callback
  });

to call populate to populate the user and meal field entries in the result.

We get the results from results in the callback.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.