Automated model registration
This commit is contained in:
54
src/database/models/spells/Ingredient.ts
Normal file
54
src/database/models/spells/Ingredient.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { DataTypes, Model, Optional } from "sequelize";
|
||||
|
||||
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
|
||||
|
||||
interface IngredientAttributes {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
|
||||
published: boolean
|
||||
}
|
||||
|
||||
interface IngredientCreationAttributes extends Optional<IngredientAttributes, 'id'> { }
|
||||
|
||||
class Ingredient extends Model<IngredientAttributes, IngredientCreationAttributes> implements IngredientAttributes {
|
||||
public id!: number
|
||||
public name!: string
|
||||
public description!: string
|
||||
|
||||
public published: boolean
|
||||
|
||||
public readonly createdAt!: Date;
|
||||
public readonly updatedAt!: Date;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
Ingredient.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
autoIncrement: true,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
published: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
}
|
||||
},
|
||||
{
|
||||
tableName: 'ingredient',
|
||||
sequelize: AuracleDatabaseDriver,
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user