Closed faavictoriano closed 8 years ago
If you're publishing the data already, the simplest option is to use Groups as the collection, and then have a field like
{ key: '_id',
label: 'Users',
fn: function (groupId) {
var userGroups = UserGroups.find({groupId: groupId}).fetch();
// format the users list to display and return it
}
}
i user this, and solve
'groupChatTable': function () {
return {
collection: Groups,
rowsPerPage: 10,
showFilter: true,
fields: [ { key: 'Name', label: 'Group Name'},
{ key: '_id', label: 'Members',
fn: function(value) {
var usersGroups = UsersGroups.find({GroupFID: value}).fetch();
var users = [];
_.each(_.values(usersGroups), function(u){
var user = Meteor.users.findOne({_id:u.UserFID});
users.push(user.username);
})
return users.length;}
},
{ key: '_id', label: 'Users',
fn: function(value) {
var usersGroups = UsersGroups.find({GroupFID: value}).fetch();
var users = [];
_.each(_.values(usersGroups), function(u){
var user = Meteor.users.findOne({_id:u.UserFID});
users.push(user.username);
})
return users;}
}]
};
}
I have two collections
Group:
UserGroups
How to render in table and group the same GroupID, and return all user in single group. But i still working now, i try to reverse the collection..