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,
|
||||
}
|
||||
)
|
||||
}
|
||||
54
src/database/models/spells/MetaSchool.ts
Normal file
54
src/database/models/spells/MetaSchool.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { DataTypes, Model, Optional } from "sequelize";
|
||||
|
||||
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
|
||||
|
||||
interface MetaSchoolAttributes {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
|
||||
published: boolean
|
||||
}
|
||||
|
||||
interface MetaSchoolCreationAttributes extends Optional<MetaSchoolAttributes, 'id'> { }
|
||||
|
||||
class MetaSchool extends Model<MetaSchoolAttributes, MetaSchoolCreationAttributes> implements MetaSchoolAttributes {
|
||||
public id!: number
|
||||
public name!: string
|
||||
public description!: string
|
||||
|
||||
public published: boolean
|
||||
|
||||
public readonly createdAt!: Date;
|
||||
public readonly updatedAt!: Date;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
MetaSchool.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: 'meta-school',
|
||||
sequelize: AuracleDatabaseDriver,
|
||||
}
|
||||
)
|
||||
}
|
||||
54
src/database/models/spells/School.ts
Normal file
54
src/database/models/spells/School.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { DataTypes, Model, Optional } from "sequelize";
|
||||
|
||||
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
|
||||
|
||||
interface SchoolAttributes {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
|
||||
published: boolean
|
||||
}
|
||||
|
||||
interface SchoolCreationAttributes extends Optional<SchoolAttributes, 'id'> { }
|
||||
|
||||
class School extends Model<SchoolAttributes, SchoolCreationAttributes> implements SchoolAttributes {
|
||||
public id!: number
|
||||
public name!: string
|
||||
public description!: string
|
||||
|
||||
public published: boolean
|
||||
|
||||
public readonly createdAt!: Date;
|
||||
public readonly updatedAt!: Date;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
School.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: 'school',
|
||||
sequelize: AuracleDatabaseDriver,
|
||||
}
|
||||
)
|
||||
}
|
||||
87
src/database/models/spells/Spell.ts
Normal file
87
src/database/models/spells/Spell.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { DataTypes, Model, Optional } from "sequelize";
|
||||
|
||||
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
|
||||
|
||||
interface SpellAttributes {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
|
||||
level: number
|
||||
charge: number
|
||||
cost: string
|
||||
isRitual: boolean
|
||||
|
||||
published: boolean
|
||||
public: boolean
|
||||
}
|
||||
|
||||
interface SpellCreationAttributes extends Optional<SpellAttributes, 'id'> { }
|
||||
|
||||
class Spell extends Model<SpellAttributes, SpellCreationAttributes> implements SpellAttributes {
|
||||
public id!: number
|
||||
public name!: string
|
||||
public description!: string
|
||||
|
||||
public level: number
|
||||
public charge: number
|
||||
public cost: string
|
||||
public isRitual: boolean
|
||||
|
||||
public published: boolean
|
||||
public public: boolean
|
||||
|
||||
public readonly createdAt!: Date;
|
||||
public readonly updatedAt!: Date;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
Spell.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
autoIncrement: true,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
level: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
charge: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '0'
|
||||
},
|
||||
isRitual: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
},
|
||||
|
||||
published: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
},
|
||||
public: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: 'spell',
|
||||
sequelize: AuracleDatabaseDriver,
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user