我试图查找结果的计数,但我不确定如何使用它。任何人都可以建议帮助
exports.shownotifications = function (req, res) {
var params = req.params;console.log(params)
var record= db.collection('requests');
var item = {"sent_id": params.id,"status":1};console.log(item)
record.find(item).toArray((err, result) => {
if (err){ return console.log(err)
}
if(result){
response = {status:'success',data:result};console.log(response)
} else{
response = {status:'fail',data:[]};
}
res.send(response);
});
};
答案 0 :(得分:0)
exports.shownotifications = function(req, res) {
var params = req.params;
var record = db.collection('requests');
var item = {
"sent_id": params.id,
"status": 1
};
record.count(item), (err, result) => {
if (err) {
}
if (result) {
response = {
status: 'success',
data: result
};
} else {
response = {
status: 'fail',
data: []
};
}
res.send(response);
}
};