findall() function in mongodb?

Question

I have a login collection with phone number, password. A user has two accounts with the same phone number and password. Check the following. I want to find all the details of the user.

apiRoutes.post('/authenticate', function(req, res) {
    staffModel.find({},{'mobile': req.body.mobile},function(err, user) {
        console.log(user);

            if (err) {
                return console.log(err);
            }

In the above example, find was not working, where as following was working. Why? And i want to get all the documents, not a single document.

 staffModel.findOne({'mobile': req.body.mobile},function(err, user) {

Show source
| find   | node.js   | mongoose   | mongodb   2017-10-23 13:10 0 Answers

Answers to findall() function in mongodb? ( 0 )

Leave a reply to - findall() function in mongodb?

◀ Go back