Hi everyone, I have been trying to fix this issue for a few hours:
I want each client to able to access a collection of all my users but only be able to access certain fields.
Here is the main page that will be using this:
import React from 'react';
import ReactDOM from 'react-dom';
import TrackerReact from 'meteor/ultimatejs:tracker-react';
import Row from '/imports/ui/components/Row';
export default class UserSearch extends TrackerReact(React.Component){
constructor(){
super();
this.state = {
subscription: {
users: Meteor.subscribe("allUsers")
}
}
}
componentWillUnmount(){
this.state.subscription.users.stop();
}
componentDidMount(){
$('#dynatable').dynatable();
}
allUsers(){
return Meteor.users.find();
}
render(){
return (
<div className="dynatable-demo">
<br/><br/><br/><br/>
<table id="dynatable" className="table table-bordered user-search-table">
<thead>
<tr>
<th>Username</th>
<th>Level</th>
<th>Points</th>
</tr>
</thead>
<tbody>
{this.allUsers().map((user) => {
return <Row
key={user._id}
user={user}
/>
})}
</tbody>
</table>
</div>
)
}
}
The publish file is: I have no imports on it like a normal collection would:
Meteor.publish("allUsers", function(){
return Meteor.users.find({}, {fields: {username: 1, level: 1, points: 1}});
});
Currently it is only showing the current logged in user.