Below Data stored in my collection
[
{ \"_id\" : ObjectId(\"53d9feff55d6b4dd1171dd9e\"),\"name\":\"John\", \"rank\":1, \"year\":1998 ,\"class\":\"a\" ,\"tota
Although a few people have answered, but I believe complete way to do it is:
router.post('/users',function(req, res, next) {
// req.body = [{ "name":"John", "rank":1, "year":1998 },{ "name":"Sherif", "rank":1, "year":1999 }]
// mapping users to each array
const query = { $or: req.body };
// execute query
User.find(query, function(err, result) {
if (err) next(err);
console.log(result);
res.json(result);
});
});