sequelize.js - Sequelize Express multiple models -


i can't seem figure out how include multiple models.

i have 3 models. tabs, servers, , points

tabs hasmany server
servers belongsto tabs , hasmany points
points belongto server

in routes doing this:

router.get('/', function (req, res, next) {     models.tabconfig.findall({       include: [models.serverconfig]     }).then(function (tabs) {       res.render('index', {         tabs: tabs,       });    }); });  module.exports = router; 

which gets me tabs, , servers associated them. works great.

but want points associated servers can iterate on tabs, servers, , points.

any ideas?

thanks

at first glance, can use eager loading multiple models:

models.tabconfig.findall({     include: [{         model: models.serverconfig,         include: [models.points]     }] }) 

that should give array tabs , servers, , inside each server have points associated it.

[{     some: 'tab',     saved: 'property',     servers: [{         some: 'server',         saved: 'property',         points: [...]     }, ...] }, ...] 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -