V
V
Valery Orlov2018-11-08 13:09:58
JavaScript
Valery Orlov, 2018-11-08 13:09:58

How to add a selection condition?

Good day.
The code below selects news from the collection by username.
How to supplement the selection condition also by the user's last name?
It should be taken into account that the surname is not indicated for all users, i.e. somewhere it simply can not be!
Condition: если req.body.nameor req.body.surnamefound in b.d.

News.find({ name: req.body.name })
 .select()
 .exec()
 .then(dev => {
   if (dev.length >= 1) {     
        res.status(200).json({
             "result":"ok"
       	});
   }
 });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question