0

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 ?

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
Ricklemer
  • 201
  • 1
  • 2
  • 10
  • If the sub document is called Widgets (capital W) you might wanna put `test.Widgets` to access the sub document – tim Oct 29 '13 at 16:47

1 Answers1

2

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 }});
});
Pent
  • 1,049
  • 15
  • 17