{"size": 856, "ext": "js", "max_stars_repo_path": "src/objectservices/Skill.js", "max_stars_repo_name": "ces-duchoang/resumelysis-bk", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/objectservices/Skill.js", "max_issues_repo_name": "ces-duchoang/resumelysis-bk", "max_issues_repo_issues_event_min_datetime": "2021-09-01T23:54:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T23:54:17.000Z", "max_forks_repo_path": "src/objectservices/Skill.js", "max_forks_repo_name": "ces-duchoang/resumelysis-bk", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 20.8780487805, "max_line_length": 78, "alphanum_fraction": 0.5397196262}
const Skill = require('../models/skill');
const {
    createDoc,
    listDoc,
    getDocById,
    removeDocById,
    updateDoc
} = require('./BaseService');

const createSkill = data => createDoc(Skill, data);

const listSkill = () => listDoc(Skill);

const getSkillById = id => getDocById(Skill, id);

const removeSkillById = id => removeDocById(Skill, id);

const updateSkillById = ({ id, ...updateData }) =>
    updateDoc({ Doc: Skill, id, updateData });

const searchSkill = name =>
    Skill.find({})
        .where('name')
        .in(
            new RegExp(
                name.replace(/[!@#$%^&*()+=\-[\]\\';,./{}|":<>?~_]/g, '\\$&'),
                'i'
            )
        )
        .limit(20)
        .exec();

module.exports = {
    createSkill,
    listSkill,
    getSkillById,
    removeSkillById,
    updateSkillById,
    searchSkill
};
