有一种方法可以使用collection.find()
只返回字段的嵌套属性? 我在集合中存储了一些信息users
特别是在我添加属性profile
字段中:imagepath
。
所以我想发布用户集合,显示username
,只有属性imagepath
profile
(配置文件有额外的信息,不敏感但体积庞大)。
Meteor.publish('UsersInfo', function () {
return Meteor.users.find({},{fields:{username:1, profile.imagepath:1}});
});
问题:查询中的字段未将profile.image
识别为字段。
用
引号括起来profile.imagepath
。即:"profile.imagepath"