@knestjs/core
Version:
Knestjs search to be a Nestjs ORM in which you write the models once and only once. This is done creating migrations automatically from the models that you create.
35 lines • 1.71 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var KnestModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KnestModule = void 0;
const common_1 = require("@nestjs/common");
const knex_1 = require("knex");
const constants_1 = require("./constants");
const migrations_service_1 = require("./migrations/migrations.service");
let KnestModule = KnestModule_1 = class KnestModule {
static forRoot(config) {
return {
module: KnestModule_1,
providers: [
{ provide: constants_1.KNEX_INSTANCE, useValue: (0, knex_1.default)({ ...config.db, migrations: { directory: config.migrations.folder } }) },
{ provide: constants_1.KNEST_MIGRATIONS_CONFIG, useValue: config.migrations },
],
exports: [constants_1.KNEX_INSTANCE]
};
}
};
KnestModule = KnestModule_1 = __decorate([
(0, common_1.Module)({
providers: [migrations_service_1.MigrationsService],
exports: [migrations_service_1.MigrationsService],
}),
(0, common_1.Global)()
], KnestModule);
exports.KnestModule = KnestModule;
//# sourceMappingURL=knest.module.js.map