MEAN App - 无法在我的查找请求中使用查询
MEAN App - Can't use query in my find request
我目前很难在我的 MEAN 应用程序中使用查询。
具体来说,我正在尝试获取与搜索字段中的输入相匹配的数据:
$scope.searchInput = function(search){
$http({
method: 'GET',
url: '/search',
params: {'licensor.name' : search}
})
.success(
function(success){
console.log(success)
})
.error(
function(error){
console.log(error)
});
}
在服务器端,我的代码如下所示:
app.get('/search', function(req,res){
ImportCollection.find(function(err, imports){
if(err) throw err
res.json(imports)
});
});
这总是 returns 完整的合集。
有什么想法吗?
请使用查找函数传递您的查询,如果您传递参数,您的请求将有一些查询参数。
例如 -
app.get('/search', function(req,res){
ImportCollection.find(req.query).exce(function(err, imports){
if(err) throw err
res.json(imports)
});
});
谢谢
我目前很难在我的 MEAN 应用程序中使用查询。
具体来说,我正在尝试获取与搜索字段中的输入相匹配的数据:
$scope.searchInput = function(search){
$http({
method: 'GET',
url: '/search',
params: {'licensor.name' : search}
})
.success(
function(success){
console.log(success)
})
.error(
function(error){
console.log(error)
});
}
在服务器端,我的代码如下所示:
app.get('/search', function(req,res){
ImportCollection.find(function(err, imports){
if(err) throw err
res.json(imports)
});
});
这总是 returns 完整的合集。 有什么想法吗?
请使用查找函数传递您的查询,如果您传递参数,您的请求将有一些查询参数。
例如 -
app.get('/search', function(req,res){
ImportCollection.find(req.query).exce(function(err, imports){
if(err) throw err
res.json(imports)
});
});
谢谢