"use strict";
/**
 * 车场镜像库
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.knexInstance = exports.generateMySqlKnexInstance = void 0;
var mslib_1 = require("mslib");
var typescript_ioc_1 = require("typescript-ioc");
var Contants_1 = require("./Contants");
/**
 * 生成mysql knex实例，外部只需给定配置的connection部分即可，其他配置已给定的默认值(适应非标)，具体配置参考knex/mysql
 * @param config
 * @returns
 */
function generateMySqlKnexInstance(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));
}
exports.generateMySqlKnexInstance = generateMySqlKnexInstance;
/**
 * 镜像车场knex实例，依赖ioc配置'config.parkImageKnex',配置参考knex/mysql
 */
exports.knexInstance = null;
var config = typescript_ioc_1.Container.getValue('config.parkImageKnex');
if (config) {
    exports.knexInstance = generateMySqlKnexInstance(config);
}
//# sourceMappingURL=ParkImage.js.map