我正在尝试对我的数据库运行查询,如下所示:
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 并没有帮助。