Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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]+'()');
}
}
@Ivan-Feofanov

This comment has been minimized.

Copy link
Owner Author

Ivan-Feofanov commented Nov 19, 2017

Instead of %yourSequelizeModel% use your model

@heisian

This comment has been minimized.

Copy link

heisian commented Mar 31, 2018

this is awesome, thank you!

@deezone

This comment has been minimized.

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
You can’t perform that action at this time.