如何返回除当前登录用户以外的Meteor.users内的所有用户?
问题描述:
我在我的数据库中有一个主用户,应该能够查看系统中的所有用户。如何返回除当前登录用户以外的Meteor.users内的所有用户?
这是我的代码,返回集合中的所有用户。
Template.listEmployees.helpers({
employees: function() {
return Meteor.users.find({}, { sort: {createdAt: -1}});
}
});
是否有可能返回除当前登录用户以外的所有用户?
答
只排除其_id
:
Template.listEmployees.helpers({
employees() {
return Meteor.users.find({ _id: { $ne: Meteor.userId() }}, { sort: { createdAt: -1 }});
}
});