const { File } = require('../model/index');

export default class FileRepository {

    async get(query : object = {}) {
        const file = await File.find(query);
        return file;
    }

    async getFirst(query : object = {}) {
        const file = await File.findOne(query);
        return file;
    }

    async create(file : File) {
        let data = {};
        data = await File.create(file);
        return data;
    }

    async update(file : any) {
        let data = {};
        data = await File.updateOne(file);
        return data;
    }

    async delete(id : any) {
        let data : any;
        data = await File.deleteOne({_id : id})
        return {status: `${(data.deletedCount > 0)}`};
    }
}
