<commit_before>'use strict';

var TasksModel = function TasksModelConstructor() {
    return [{
        title: 'one',
        createdAt: new Date(),
        updatedAt: new Date(),
        completed: false,
        members: [],
        owner: 'me'
    }, {
        title: 'two',
        createdAt: new Date(),
        updatedAt: new Date(),
        completed: true,
        members: [],
        owner: 'me'
    }];
};


module.exports = TasksModel;
<commit_msg>feat(Tasks): tie tasks public model to DB<commit_after>'use strict';

var _ = require('lodash');

var Tasks = require('../lib/dbModels/Tasks');

var TasksModel = function TasksModelConstructor() {
    return {
        /**
         * Find tasks and execute callback
         * @param {Number} [id] ID of the task
         * @param {Function} cb Callback to execute after we found tasks
         * @returns {*}
         */
        get: function (id, cb) {
            if (_.isUndefined(cb) && _.isFunction(id)) {
                cb = id;
                id = null;
            }

            if (_.isNull(id)) {
                return Tasks.all()
                    .then(function (results) {
                        cb(null, results);
                    })
                    .catch(function (err) {
                        cb(err);
                    });
            }
            else {
                return Tasks.findOne({ where: { id: id } })
                    .then(function (results) {
                        cb(null, results);
                    })
                    .catch(function (err) {
                        cb(err);
                    });
            }
        },
        post: function (task, cb) {
            return Tasks.create(task)
                .then(function (err, result) {
                    if (err) {
                        cb(err);
                        return;
                    }

                    cb(null, result);
                })
                .catch(function (err) {
                    cb(err);
                });
        },
        put: function (id, task, cb) {
            return Tasks.update(task, { where: { id: id } })
                .then(function () {
                    console.log(arguments);
                })
        },
        delete: function (id, cb) {
            return Tasks.destroy({ where: { id: id } })
                .then(function () {
                    console.log(arguments);
                })
        }
    }
};


module.exports = TasksModel();

{'fraction_non_alphanumeric': 0.12355057976809276, 'fraction_numerical': 0.0, 'mean_word_length': 1.0474631751227497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '58261', 'n_tokens_mistral': 666, 'n_tokens_neox': 628, 'n_words': 154}