{% for relation in table.o2mRelations.array -%} {% if c.hasOne[hasOneAlias(relation)] -%} {# If it is listed in hasOne. #} {% set cr = c.hasOne[hasOneAlias(relation)] -%} {# Custom data of relation #} {{ modelName(table) }}.hasOne({{ modelName(relation.targetTable) }}, { {% if options.generateAliases -%} as : {{ cr.as or (hasOneAlias(relation).val | singleQuote) }},{% if cr.as -%} // as: "{{ hasOneAlias(relation) }}"{% endif %} {% endif -%} {% else %} {% set cr = c.hasMany[hasManyAlias(relation)] -%} {# Custom data of relation #} {{ modelName(table) }}.hasMany({{ modelName(relation.targetTable) }}, { {% if options.generateAliases -%} as : {{ cr.as or (hasManyAlias(relation).val | singleQuote) }},{% if cr.as -%} // as: "{{ hasManyAlias(relation) }}"{% endif %} {% endif -%} {% endif -%} foreignKey: {{ cr.foreignKey or (relation.constraint.columns.array[0].name | singleQuote) }}, {# Sequelize supports only single column FK :( #} onDelete : {{ cr.onDelete or (relation.constraint.onDelete | singleQuote) }}, onUpdate : {{ cr.onUpdate or (relation.constraint.onUpdate | singleQuote) }} }); {% endfor %}