大家好,我已经尝试过这种方法来从 Meteor.users 数组中获取信息,但它不起作用,我不知道如何解决这个问题。提前致谢!
发布用户
Deps.autorun(function (handle) {
Meteor.publish('directory', function () {
if (this.userId) {
var user = Meteor.users.findOne(this.userId);
var x = user.profile.x;
return Meteor.users.find({"profile.x": x});
} else {
handle.stop();
}
});
});
Meteor.users.allow({
remove:function() {
var user = Meteor.user();
var x = user.profile.x;
if(x === "admin") {
return true;
} else {
return false;
}
},
});
帮手:
listTeam: function () {
var userTeam = Meteor.users.find({}).fetch();
return _.map(userTeam || [], function(user) { return user.emails[0].address || user._id;});
},
模板:
<ul>
{{#each listTeam}}
<div>
<li id="item">{{this}}</li><button id="deleteTeam" class="button">Delete</button>
</div>
{{/each}}
</ul>
第一种方法:
'click #deleteTeam': function (event, template) {
var id = template.data._id;
Meteor.users.remove({_id:id});
}
返回未定义(仅在迭代的第一项中)
我已经尝试过使用 jQuery,但它没有用,因为我只获得了电子邮件地址和第一项。(我没有迭代 id,我认为这似乎不是一个好的解决方案)。