Migrated the Media.ts model

This commit is contained in:
Mathias Wagner 2023-11-07 09:17:20 +01:00
parent 41ca7ec669
commit 606df61f2c
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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<InferAttributes<IMedia>, InferCreationAttributes<IMedia>> {
assetId?: string
clientId: number
assetName: string
assetEnding: string
assetDescription: string
created: Date
assetDescription?: string
created?: Date
}
const MediaSchema = new Schema<IMedia>({
const MediaSchema = sequelize.define<IMedia>('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);
export const Media = MediaSchema;