<commit_before>'use strict';

function dbMongoose(q) {

    function qDbMongoose(options) {

        var operation = options.operation || 'find',
            query = options.query || {},
            model = options.source;

        function qGetDB(resolve, reject) {
            if (!model) {
                reject('no model');
            }

            function dbCallback(err, data) {
                if (err) {
                    reject(err);
                } else {
                    resolve(data);
                }
            }

            model[operation](query, dbCallback);
        }

        return new q.Promise(qGetDB);
    }


    q.dbMongoose = qDbMongoose;

    return q;<commit_msg>Adding conditions to support CRUD operations required by Mongoose for operations such as update etc<commit_after>'use strict';

function dbMongoose(q) {

    function qDbMongoose(options) {

        var operation = options.operation || 'find',
            query = options.query || {},
            conditions = options.conditions || null,
            model = options.source;

        function qGetDB(resolve, reject) {
            if (!model) {
                reject('no model');
            }

            function dbCallback(err, data) {
                if (err) {
                    reject(err);
                } else {
                    resolve(data);
                }
            }

            conditions ? model[operation](conditions, query, dbCallback) : model[operation](query, dbCallback);
        }

        return new q.Promise(qGetDB);
    }


    q.dbMongoose = qDbMongoose;

    return q;
{'fraction_non_alphanumeric': 0.10223048327137546, 'fraction_numerical': 0.0, 'mean_word_length': 1.465648854961832, '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': '6136738', 'n_tokens_mistral': 436, 'n_tokens_neox': 403, 'n_words': 96}