I'm using Sails beta 0.10.0-rc7 and I'm having troubles with model associations. I have the following scheme:
Document - has - Attributes -- have -- Type
Documents that have attributes, which have a Type. I'm trying to retrieve the whole structure from only one query using populate:
var query = model.findOne({id: id});
for (var i = 0; i < model.associations.length; i++) {
query = query.populate(model.associations[i].alias);
}
With that code I can get the 1st level of the Model populated:
res = {
id: 1,
name: '....',
desc: '....',
// This is populated
attributes: [{
id: 1,
name: '...',
// THIS Should be populated also!
type: 1
// Should be
// type: { id: 1, name: '....' .... }
}
]
}
How could I get the 2nd level of hierarchy (Type) ?
Thanks in advance :_)