mne*_*dev 1 javascript api loopback mongodb apiconnect
我正在使用loopback为我的应用程序提供api服务,我尝试更改一些数据的GET请求.
截至目前,查询将获取特定API的所有结果:
People.find({
where: {
'town': 'name of a town'
}
}).$promise
// Promise is fulfilled and people returned
.then(function(results) {
$scope.people = results;
})
// Promise is rejected and error catched
.catch(function(err) {
$scope.errors.PeopleFind = JSON.stringify(err.data.error.message ?
err.data.error.message :
err.data.error.errmsg
);
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试过在where子句中添加单引号或者做类似的事情.find({ where : { town : 'name of a town' }}.无论我把引号放在哪里,结果总是整个包.我如何查询我感兴趣的结果?
提前致谢
我找到答案归功于一位同事,我会在这里写下答案
Run Code Online (Sandbox Code Playgroud)People .find({ filter: { where: {Town : currentUserTown} } })
回送框架的文档没有声明您需要应用过滤器对象来实际过滤结果,实际上您可以使用他们编写的示例来检查文档:
Cars.find({where: {carClass:'fullsize'}});
Run Code Online (Sandbox Code Playgroud)
在where子句对象之前,您需要编写包含该子句的过滤器对象,这应该可以解决查询问题.
| 归档时间: |
|
| 查看次数: |
2426 次 |
| 最近记录: |