const { connect, disconnect } = require('../config/db');
const { User } = require('../model/index');

export default class UserRepository {

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

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

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

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

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