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

export default class FileRepository {

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

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

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

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

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