Backend/models/Media.ts

41 lines
1.1 KiB
TypeScript

import {sequelize} from "../app";
import * as crypto from "crypto";
import {DataTypes, InferAttributes, InferCreationAttributes, Model} from "sequelize";
export interface IMedia extends Model<InferAttributes<IMedia>, InferCreationAttributes<IMedia>> {
assetId?: string
clientId: number
assetName: string
assetEnding: string
assetDescription?: string
created?: Date
}
const MediaSchema = sequelize.define<IMedia>('media', {
assetId: {
type: DataTypes.STRING,
defaultValue: () => crypto.randomBytes(12).toString('hex')
},
clientId: {
type: DataTypes.BIGINT,
allowNull: false
},
assetName: {
type: DataTypes.STRING,
defaultValue: "Sheepstar Asset"
},
assetDescription: {
type: DataTypes.STRING,
defaultValue: "Well I dont know what this is for"
},
assetEnding: {
type: DataTypes.STRING,
defaultValue: "txt"
},
created: {
type: DataTypes.DATE,
defaultValue: Date.now
}
});
export const Media = MediaSchema;