我正在try 为应用程序开发数据聚合功能.用户应该能够输入一个名称,然后在数据库集合中搜索该名称并返回集合.
控制器:
exports.DAFacility_author_search = (req, res) => {
DAFacility.aggregate([
[
{
'$match': {
'author': author
}
}
]
]).then((DAFacility) => {
res.send(DAFacility);
})
.catch((e) => {
res.send(e);
});
};
路由:
router.get('/DAFacilityAuthor', DAFacilityController.DAFacility_author_search)
对于'author': author
,我试图使用author作为变量名,但我不知道如何构造控制器和路由,以便接收参数,以便在postman上检索值.