javascript - Nested relations with Sequelize -



javascript - Nested relations with Sequelize -

i using sequelize node + mysql.

i have model construction similar this:

class="lang-js prettyprint-override">// models: var group, issue, invite; // many issues per grouping group.hasmany(issue); issue.belongsto(group); // groups can invite other groups work on issues issue.hasmany(invite, {foreignkey: groupid}); invite.belongsto(issue, {foreignkey: groupid}); group.hasmany(invite, {foreignkey: inviteeid}); invite.belongsto(group, {foreignkey: inviteeid}); // given issue id, include invites + invited groups (inviteeid) - how? var query = { where: {id: ...}, include: ??? }; issue.find(query).complete(function(err, issue) { var invites = issue.invites; var firstinvitedgroup = issue.invites[0].group; // ... });

is @ possible? possible work-arounds? give thanks you!

issue.find({ include: [ { model: invite, include: [group] } ] });

http://sequelize.readthedocs.org/en/latest/docs/models-usage/index.html#nested-eager-loading

javascript mysql sequelize.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -