【发布时间】:2015-12-06 21:39:51
【问题描述】:
我正在尝试对我的数据库运行如下查询:
filter.customerProfile = { $exists: true };
console.log("filter: " + JSON.stringify(filter));
this.accountsAPI.find(filter, cb);
在我打印的回调中:
console.log('first element: ', JSON.stringify(accounts[0]));
我的输出:
filter: {"customerProfile":{"$exists":true}}
first element: {"username":"aabrahams","firstName":"Arthur","lastName":"Abrahams","DOB":"1981-07-11","email":"aabrahams@gmail.com","adminProfile":[{"displayUsername":"Art Abrahams","active":true,"priceEdits":[],"products":[],"productEdits":[],"jobCancellationApprovals":[],"partnerApprovals":[]}],"_id":"TkJNoSogUaJFKIHU"}
基本上,它返回所有用户,不仅是那些具有“customerProfile”的用户,而且我使用的过滤器甚至都无关紧要。我尝试添加 "$ne":null 并没有帮助。
【问题讨论】:
-
你能分享一段格式更好的代码吗?比如 this.accountsAPI 是什么。
-
accountsAPI是feathers提供的服务。
-
feathers mongo 接口导出:find(params, cb): void;
标签: javascript json node.js mongodb feathersjs