From 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Dec 2017 17:53:50 +0100 Subject: Move models to typescript-sequelize --- server/models/avatar/avatar-interface.ts | 16 ---------------- server/models/avatar/avatar.ts | 31 ++++++++++++------------------- server/models/avatar/index.ts | 1 - 3 files changed, 12 insertions(+), 36 deletions(-) delete mode 100644 server/models/avatar/avatar-interface.ts delete mode 100644 server/models/avatar/index.ts (limited to 'server/models/avatar') diff --git a/server/models/avatar/avatar-interface.ts b/server/models/avatar/avatar-interface.ts deleted file mode 100644 index 4af2b87b7..000000000 --- a/server/models/avatar/avatar-interface.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as Sequelize from 'sequelize' - -export namespace AvatarMethods {} - -export interface AvatarClass {} - -export interface AvatarAttributes { - filename: string -} - -export interface AvatarInstance extends AvatarClass, AvatarAttributes, Sequelize.Instance { - createdAt: Date - updatedAt: Date -} - -export interface AvatarModel extends AvatarClass, Sequelize.Model {} diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts index 96308fd5f..2e7a8ae2c 100644 --- a/server/models/avatar/avatar.ts +++ b/server/models/avatar/avatar.ts @@ -1,24 +1,17 @@ -import * as Sequelize from 'sequelize' -import { addMethodsToModel } from '../utils' -import { AvatarAttributes, AvatarInstance } from './avatar-interface' +import { AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' -let Avatar: Sequelize.Model +@Table({ + tableName: 'avatar' +}) +export class AvatarModel extends Model { -export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { - Avatar = sequelize.define('Avatar', - { - filename: { - type: DataTypes.STRING, - allowNull: false - } - }, - {} - ) + @AllowNull(false) + @Column + filename: string - const classMethods = [] - addMethodsToModel(Avatar, classMethods) + @CreatedAt + createdAt: Date - return Avatar + @UpdatedAt + updatedAt: Date } - -// ------------------------------ Statics ------------------------------ diff --git a/server/models/avatar/index.ts b/server/models/avatar/index.ts deleted file mode 100644 index 877aed1ce..000000000 --- a/server/models/avatar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './avatar-interface' -- cgit v1.2.3