Skip to content

Instantly share code, notes, and snippets.

@Ivan-Feofanov
Last active July 25, 2023 19:24
Show Gist options
  • Save Ivan-Feofanov/eefe489a2131f3ec43cfa3c7feb36490 to your computer and use it in GitHub Desktop.
Save Ivan-Feofanov/eefe489a2131f3ec43cfa3c7feb36490 to your computer and use it in GitHub Desktop.
Get list of association methods of model in Sequelize
const model = %yourSequelizeModel%
for (let assoc of Object.keys(model.associations)) {
for (let accessor of Object.keys(model.associations[assoc].accessors)) {
console.log(model.name + '.' + model.associations[assoc].accessors[accessor]+'()');
}
}
@deezone
Copy link

deezone commented Mar 12, 2019

Amazing! Very, very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment