2015-04-03 43 views
0

我正在使用流星。我在数据库中有一个用户,在'个人资料' - >接受了一个额外的字段。我通过db.users.find()检查'accepted'的值,值为true。 所以,我的查询(返回0):我的mongo查询(流星)有什么问题?

//index.js 
fooFunc: function(){return Meteor.users.find({accepted: true}, {fields:{'profile': 1}}).count();} 

该查询返回1:

//index.js 
fooFunc: function(){return Meteor.users.find({}, {fields:{'profile': 1}}).count();} 

为什么第一个查询返回0?

回答

2

您的第一个查询将搜索accepted字段值为true的用户数。但您的用户没有accepted字段。他们有profile.accepted

因此,

Meteor.users.find({'profile.accepted' : true}, 
    {fields:{'profile': 1}}).count();