我正在尝试对我要返回的用户集合进行排序。具体来说,我想在profile.lastlogin中对UNIX时间戳进行排序。所以我认为下面的代码可以工作但不幸的是,流星总是会抛出意外令牌(profile.lastlogin中的点)的错误。我有什么想法我做错了吗?没有任何fieldname.fieldname notatin的普通集合的正常排序正常。
Template.profiles.helpers({
filteredUsers: function () {
return Meteor.users.find({
$and: [
{'_id': { $ne: Meteor.userId()} }, {'profile.interestone': Meteor.user().profile.interestone}
]
}, {sort: {profile.lastlogin: 1}});
}
});
答案 0 :(得分:3)
使用点表示法访问数组元素或嵌入文档的字段时,需要将语句括在引号中:' some.thing'。在您的情况下将是
{sort: {'profile.lastlogin': 1}}