Categories
JavaScript Answers

How to get full list of users with Mongoose?

Spread the love

Sometimes, we want to get full list of users with Mongoose.

In this article, we’ll look at how to get full list of users with Mongoose.

How to get full list of users with Mongoose?

To get full list of users with Mongoose, we can use the User.find method.

For instance, we write

User.find({}, (err, users) => {
  console.log(users)
});

to call User.find with an empty object to retrieve the full list of users.

The full users list is stored in the users parameter as an array.

Conclusion

To get full list of users with Mongoose, we can use the User.find method.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published. Required fields are marked *