{% for column in table.columns.array -%} {% set cc = custom[modelName(table)].attributes[attributeName(column)] -%} {# Custom Data for this attrbute i.e. "custom.Account.attributes.surname" #} {{ attributeName(column) }}: { type: {{ (cc.type or util.sequelizeType(column)) }}, field: {{ (cc.name or column.name) | singleQuote }}, allowNull: {{ cc.allowNull or column.allowNull }} {%- if cc.default or (column.default | clearDefault) -%} ,defaultValue: {{ cc.default or (column.default | clearDefault) }} {% endif -%} {%- if cc.unique or column.uniqueIndexesNoPK.array[0] -%} ,unique: {{ cc.unique or (column.uniqueIndexesNoPK.array[0].name | singleQuote) }} {% endif -%} {%- if cc.primaryKey or column.isPrimaryKey -%} ,primaryKey: {{ cc.primaryKey or 'true' }} {% endif -%} {%- if cc.autoIncrement or column.isAutoIncrement -%} ,autoIncrement: {{ cc.autoIncrement or 'true' }} {% endif -%} {%- if cc.comment or column.comment -%} ,comment: {{ (cc.comment or (column.comment | singleQuote)) | singleLine }} {% endif -%} {%- if cc.references or column.referencedColumns.array[0] -%} ,references: { model: {{ cc.references.model or (column.referencedColumns.array[0].table.name | singleQuote) }}, key: {{ cc.references.key or (column.referencedColumns.array[0].name | singleQuote) }} } {% endif -%} {%- if cc.onUpdate or column.foreignKeyConstraints.array[0].onUpdate -%} ,onUpdate: {{ cc.onUpdate or (column.foreignKeyConstraints.array[0].onUpdate | singleQuote) }} {% endif -%} {%- if cc.onDelete or column.foreignKeyConstraints.array[0].onDelete -%} ,onDelete: {{ cc.onDelete or (column.foreignKeyConstraints.array[0].onDelete | singleQuote) }} {% endif -%} {%- for key, value in cc -%} {# Custom attribute details from custom data not found in template #} {%- if not (key == 'type' or key == 'name' or key == 'allowNull' or key == 'default' or key == 'defaultValue' or key == 'unique' or key == 'primaryKey' or key == 'autoIncrement' or key == 'comment' or key == 'references' or key == 'onUpdate' or key == 'onDelete') -%} ,{{ key }}: {{ value | stringifyIfObject }} {% endif -%} {% endfor -%} }{% if not loop.last -%},{% endif -%} {% endfor %}