From 61ec2ca8e2769fe2d1c8510954428f7ac1458a7e Mon Sep 17 00:00:00 2001 From: mohjaps Date: Thu, 13 Oct 2022 12:32:13 +0300 Subject: [PATCH] Change Class To Interface Related #44 --- server/models/reviews.ts | 34 ++++++++++++++++----------------- server/models/transactions.ts | 32 +++++++++++++++---------------- server/models/users.ts | 36 +++++++++++++++++------------------ 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/server/models/reviews.ts b/server/models/reviews.ts index c570c29..88a0671 100644 --- a/server/models/reviews.ts +++ b/server/models/reviews.ts @@ -5,31 +5,34 @@ import { CreationOptional, DataTypes, } from 'sequelize'; -import sequelize from '../database/connection'; +import sequelize from '../database/config/connection'; -export class Reviews extends Model< -InferAttributes, -InferCreationAttributes -> { - declare id: CreationOptional; +interface ReviewsModel + extends Model< + InferAttributes, + InferCreationAttributes + > { + id: CreationOptional - declare title?: string; + title?: string - declare description?: Text; + description?: Text - declare points?: number; + points?: number - declare is_shown?: boolean; + is_shown?: boolean - declare creation_date?: Date; + creation_date?: Date - declare user_id?: number; + user_id?: number } -Reviews.init( +const Reviews = sequelize.define( + 'Reviews', { id: { - type: DataTypes.GUID, + type: DataTypes.UUID, + defaultValue: DataTypes.UUIDV4, autoIncrement: true, primaryKey: true, }, @@ -62,9 +65,6 @@ Reviews.init( allowNull: false, }, }, - { - sequelize, - }, ); export default Reviews; diff --git a/server/models/transactions.ts b/server/models/transactions.ts index 2108aac..e95c0e5 100644 --- a/server/models/transactions.ts +++ b/server/models/transactions.ts @@ -4,28 +4,31 @@ import { InferCreationAttributes, CreationOptional, DataTypes, -} from "sequelize"; -import sequelize from "../database/connection"; +} from 'sequelize'; +import sequelize from '../database/config/connection'; -export class Transactions extends Model< -InferAttributes, -InferCreationAttributes -> { - declare id: CreationOptional; +interface TransactionsModel + extends Model< + InferAttributes, + InferCreationAttributes + > { + id: CreationOptional - declare title?: string; + title?: string - declare description?: Text; + description?: Text - declare creation_date?: Date; + creation_date?: Date - declare user_id?: number; + user_id?: number } -Transactions.init( +const Transactions = sequelize.define( + 'Transactions', { id: { - type: DataTypes.GUID, + type: DataTypes.UUID, + defaultValue: DataTypes.UUIDV4, autoIncrement: true, primaryKey: true, }, @@ -46,9 +49,6 @@ Transactions.init( allowNull: false, }, }, - { - sequelize, - } ); export default Transactions; diff --git a/server/models/users.ts b/server/models/users.ts index 593d003..7a69712 100644 --- a/server/models/users.ts +++ b/server/models/users.ts @@ -5,33 +5,36 @@ import { CreationOptional, DataTypes, } from 'sequelize'; -import sequelize from '../database/connection'; +import sequelize from '../database/config/connection'; -export class Users extends Model< -InferAttributes, -InferCreationAttributes -> { - declare id: CreationOptional; +interface UsersModel + extends Model< + InferAttributes, + InferCreationAttributes + > { + id: CreationOptional - declare first_name?: string; + first_name?: string - declare last_name?: string; + last_name?: string - declare email?: string; + email?: string - declare phone_number?: string; + phone_number?: string - declare creation_date?: Date; + creation_date?: Date - declare roles?: 'ADMIN' | 'USER'; + roles?: 'ADMIN' | 'USER' - declare hased_password?: string; + hased_password?: string } -Users.init( +const Users = sequelize.define( + 'Transactions', { id: { - type: DataTypes.GUID, + type: DataTypes.UUID, + defaultValue: DataTypes.UUIDV4, autoIncrement: true, primaryKey: true, }, @@ -71,9 +74,6 @@ Users.init( allowNull: false, }, }, - { - sequelize, - }, ); export default Users;