{% for relation in table.m2mRelations.array -%} {% set cr = c.belongsToMany[belongsToManyAlias(relation)] -%} {# Custom data of relation #} {{ modelName(table) }}.belongsToMany({{ modelName(relation.targetTable) }}, { {% if options.generateAliases -%} as : {{ cr.as or (belongsToManyAlias(relation).val | singleQuote) }},{% if cr.as -%} // as: "{{ belongsToManyAlias(relation) }}"{% endif %} {% endif -%} through : {{ modelName(relation.joinTable) }}, foreignKey: {{ cr.foreignKey or (relation.sourceConstraint.columns.array[0].name | singleQuote) }}, {# Sequelize supports only single column FK :( #} otherKey : {{ cr.otherKey or (relation.targetConstraint.columns.array[0].name | singleQuote)}}, {# Sequelize supports only single column FK :( #} onDelete : {{ cr.onDelete or (relation.sourceConstraint.onDelete | singleQuote)}}, onUpdate : {{ cr.onUpdate or (relation.sourceConstraint.onUpdate | singleQuote)}} }); {% endfor %}