I have TopPlayer model:
module.exports = {
attributes: {
league_id: 'number',
playerid: 'number',
playerimage: 'url',
teamimage:'url',
teamname:'string',
season: 'string',
player: 'string',
assets: 'number',
goals: 'number',
toJSON: function() {
var obj = this.toObject();
Player.findOne({gs_id:obj.playerid}).done(function(err, player) {
obj.playerImage = player.image;
console(player.image);// everything is ok
return obj; // but this is returning null
});
}
}
};
and toJSON return null objects always. Player is founded when i debug, but obj instance inside callback is null, and i cant return him :( How can i resolve problem like this?