javascript - Why am I only getting one association with this model? -


using sequelize node.js have defined relationships. issue promotion models contain 1 gameplaylog each instead of each. example promotion below should have on 100 gameplaylogs's. copied 1 array of returned promotions/tournaments reference. doing wrong?

var sequelize = require('sequelize'),     seqlz = new sequelize('wegweg', 'wegwegweg', 'wegwegweg!', {         host: '...',         port: '3306',         dialect: 'mysql',         timezone: 'utc-05:00',         pool: {             max: 5,             min: 0,             idle: 10000         }     }),     promotion = seqlz.define('promotion', {         tournamentid: {             type: sequelize.bigint(20),             primarykey: true         },         iconfilepath: sequelize.string,         name: sequelize.string(75),         eventstartdate: sequelize.date,         eventenddate: sequelize.date     }, {         timestamps: false,         tablename: 'tournament'     }),     advertiser = seqlz.define('advertiser', {         advertiserid: {             type: sequelize.bigint(20),             primarykey: true         },         name: sequelize.string(75),     }, {         timestamps: false,         tablename: 'advertiser'     }),     game = seqlz.define('game', {         gameid: {             type: sequelize.bigint(20),             primarykey: true         },         name: sequelize.string(75)     }, {         timestamps: false,         tablename: 'game'     }),     gameplaylog = seqlz.define('gameplaylog', {         gameplaylogid: {             type: sequelize.bigint(20),             primarykey: true         },         createddate: sequelize.date     }, {         timestamps: false,         tablename: 'gameplaylog'     });  promotion.belongsto(advertiser, {foreignkey: 'advertiserid'}); promotion.belongsto(game, {foreignkey: 'gameid'}); promotion.hasmany(gameplaylog, {foreignkey: 'gameplaylogid'});  exports.handler = function(event, context) {     promotion.findall({         where: {status: 3},         include: [advertiser, game, gameplaylog]     }).then(function(promos) {         context.done(null, promos);     }); };    {     "tournamentid": 607,     "iconfilepath": "uploadfiles/tournament/icon/...-mobile-icon.jpg",     "name": "win custom artwork",     "eventstartdate": "2015-07-27t05:00:00.000z",     "eventenddate": "2016-08-02t04:00:00.000z",     "advertiserid": 37,     "gameid": 14,     "advertiser": {       "advertiserid": 37,       "name": "...customs"     },     "game": {       "gameid": 14,       "name": "eggcetera"     },     "gameplaylogs": [       {         "gameplaylogid": 607,         "createddate": "2015-02-26t13:31:34.000z"       }     ] } 

you're specifying foreign key gameplayerlogid that's primary key in gameplayerlog table there ever 1 corresponding id. think want specify promotion id in gameplayerlog table foreign key.


Comments