I have a collections users in mongoDB with a widgets document for every user like this :
Widgets = [{
type: 'container',
size: 12,
offset: 0,
id: 'root',
children: [
{
type: 'widgetSearch',
title: 'Recherche',
offset: 0,
size: 2,
id: 'searchId',
toolbar: {
buttons: [ 'config', 'move', 'minimize', 'maximize', 'close' ]
}
},...etc
In a file client.js I want to access at Widgets data.
I try this :
var user = Meteor.user();
var test = Meteor.users.find({_id: user._id});
console.log(test.widgets);
or
console.log(test[0].widgets);
What I am doing wrong here ?
Meteor by default does not publish custom fields for User Accounts. You'll want to publish each User field required, yourself.
Meteor.publish(null, function() {
return Meteor.users.find({_id: this.userId}, {fields: {widgets: 1, profile: 1, etc: 1 }});
});