import mongoose, { Schema, Document } from 'mongoose';

export interface IStoredFile extends Document {
    filename: string;
    contentType: string;
    data: Buffer;
    size: number;
    uploadDate: Date;
}

const StoredFileSchema: Schema = new Schema({
    filename: { type: String, required: true },
    contentType: { type: String, required: true },
    data: { type: Buffer, required: true },
    size: { type: Number, required: true },
    uploadDate: { type: Date, default: Date.now }
});

export default mongoose.models.StoredFile || mongoose.model<IStoredFile>('StoredFile', StoredFileSchema);
