I need to use data that was recieved in a asynchronous way in a model 'toObject' method.
toObject: function() {
var user = this;
return q(Group.find())
.then(function(groups) {
....
return user;
});
},
toJSON: function() {
this.toObject().then(function(user) {
return user;
});
}
This does not work and breaks all the policies (user becomes unavailable).
Is there a way in which I could do this ? Thanks.