sequelize#ModelAttributes TypeScript Examples
The following examples show how to use
sequelize#ModelAttributes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelBuilder.ts From aloxide with Apache License 2.0 | 6 votes |
static mapField(
typeInterpreter: Interpreter<Field, DataType>,
fields: Field[],
key: string,
): ModelAttributes {
return fields.reduce((a, c) => {
const field: ModelAttributeColumnOptions<Model> = {
type: typeInterpreter.interpret(c),
};
if (c.name === key) {
field.primaryKey = true;
switch (field.type) {
case DataTypes.SMALLINT:
case DataTypes.INTEGER:
case DataTypes.BIGINT:
case DataTypes.NUMBER:
case DataTypes.DOUBLE:
field.autoIncrement = true;
break;
}
}
return Object.assign(a, {
[c.name]: field,
});
}, {});
}
Example #2
Source File: models.ts From aloxide with Apache License 2.0 | 5 votes |
indexStateSequelizeFields: ModelAttributes = ModelBuilder.mapField( modelBuilder.typeInterpreter, indexStateSchema.fields, indexStateSchema.key, )