Actually the question in the title, how in Mongoose to find all the data that are associated with the user, whose id = 1? I found only the findOne () method in the official documentation, followed by listing the required fields, but I did not find how to take everything at once ...
1 answer
As you can see from the documentation , the list of fields is optional.
Just do not describe the list of fields at all:
User.findOne({id: 1}).exec() // Получаем Promise .then(user=>console.log(user)); |
User.findOne({id: id}).exec().then(user=>console.log(user));- vp_arth