mongodb 过滤器不工作
mongodb filter not working
我正在尝试 运行 对我的数据库进行如下查询:
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"}
基本上,它 returns 所有用户,不仅是那些拥有 "customerProfile" 的用户,而且我使用什么过滤器甚至都不重要。我尝试添加 "$ne":null 但没有帮助。
根据 feathers' documentation 你用 query:
做了一个过滤条件
var filter = {
query: {
customerProfile: {
$exists: true
}
}
}
this.accountsAPI.find(filter, cb);
我正在尝试 运行 对我的数据库进行如下查询:
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"}
基本上,它 returns 所有用户,不仅是那些拥有 "customerProfile" 的用户,而且我使用什么过滤器甚至都不重要。我尝试添加 "$ne":null 但没有帮助。
根据 feathers' documentation 你用 query:
做了一个过滤条件var filter = {
query: {
customerProfile: {
$exists: true
}
}
}
this.accountsAPI.find(filter, cb);