diff --git a/models/Media.ts b/models/Media.ts index 93256d1..f868198 100644 --- a/models/Media.ts +++ b/models/Media.ts @@ -1,40 +1,41 @@ -import mongoose, {Schema} from 'mongoose'; +import {sequelize} from "../app"; import * as crypto from "crypto"; +import {DataTypes, InferAttributes, InferCreationAttributes, Model} from "sequelize"; -export interface IMedia { - assetId: string +export interface IMedia extends Model, InferCreationAttributes> { + assetId?: string clientId: number assetName: string assetEnding: string - assetDescription: string - created: Date + assetDescription?: string + created?: Date } -const MediaSchema = new Schema({ +const MediaSchema = sequelize.define('media', { assetId: { - type: String, - default: () => crypto.randomBytes(12).toString('hex') + type: DataTypes.STRING, + defaultValue: () => crypto.randomBytes(12).toString('hex') }, clientId: { - type: Number, - required: true + type: DataTypes.BIGINT, + allowNull: false }, assetName: { - type: String, - default: "Sheepstar Asset" + type: DataTypes.STRING, + defaultValue: "Sheepstar Asset" }, assetDescription: { - type: String, - default: "Well I dont know what this is for" + type: DataTypes.STRING, + defaultValue: "Well I dont know what this is for" }, assetEnding: { - type: String, - default: "txt" + type: DataTypes.STRING, + defaultValue: "txt" }, created: { - type: Date, - default: Date.now + type: DataTypes.DATE, + defaultValue: Date.now } }); -export const Media = mongoose.model('media', MediaSchema); \ No newline at end of file +export const Media = MediaSchema; \ No newline at end of file