"use strict";
/**
 * knex工具模块
 * @date 2022-03
 * @author 何华东
 */
Object.defineProperty(exports, "__esModule", { value: true });
var mslib_1 = require("mslib");
var Contants_1 = require("./Contants");
var KnexUtils = /** @class */ (function () {
    function KnexUtils() {
    }
    /**
     * 根据配置生成knex实例
     *
     * 默认给定了Knex所需的大部分配置，而且接入了日志，外部只需配置connection即可，
     */
    KnexUtils.generateMySqlKnexInstance = function (config) {
        var defaults = {
            client: 'mysql2',
            pool: { min: 0, max: 10 },
            debug: Contants_1.default.IS_DEBUG,
            log: {
                warn: function (message) {
                    mslib_1.logger.warn(message);
                },
                error: function (message) {
                    mslib_1.logger.error(message);
                },
                deprecate: function (message) {
                    mslib_1.logger.error(message);
                },
                debug: function (message) {
                    mslib_1.logger.debug(message);
                },
            }
        };
        return require('knex')(Object.assign(defaults, config));
    };
    return KnexUtils;
}());
exports.default = KnexUtils;
//# sourceMappingURL=KnexUtils.js.map