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
}

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"
    }
});

export const    Media = MediaSchema;