@koalarx/nest 0.0.4 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/database/entity.js
CHANGED
|
@@ -8,10 +8,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Entity = void 0;
|
|
10
10
|
const automapper_classes_1 = require("automapper-classes");
|
|
11
|
+
const list_1 = require("../utils/list");
|
|
11
12
|
class Entity {
|
|
12
13
|
id;
|
|
13
14
|
create(props) {
|
|
14
|
-
Object.
|
|
15
|
+
Object.keys(props).forEach((key) => {
|
|
16
|
+
if (Array.isArray(props[key]) && this[key] instanceof list_1.List) {
|
|
17
|
+
this[key] = new list_1.List(props[key]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this[key] = props[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
equals(obj) {
|
|
17
25
|
return obj.id === this.id;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PaginationParams } from '../../common/models/pagination-params';
|
|
2
2
|
import { PrismaClientWithCustomTransaction } from '../../services/prisma/prisma-client-with-custom-transaction.interface';
|
|
3
3
|
import { PrismaTransactionalClient } from '../../services/prisma/prisma-transactional-client';
|
|
4
|
+
import { ModelName } from '../../services/prisma/prisma.types';
|
|
4
5
|
import { Entity } from './entity';
|
|
5
6
|
export interface FindAllProps<TPaginateAndOrdering extends PaginationParams, TWhere, TInclude = any> {
|
|
6
7
|
where: TWhere;
|
|
@@ -10,7 +11,7 @@ export interface FindAllProps<TPaginateAndOrdering extends PaginationParams, TWh
|
|
|
10
11
|
export declare abstract class RepositoryBase<TEntity extends Entity<TEntity>> {
|
|
11
12
|
protected prisma: PrismaClientWithCustomTransaction;
|
|
12
13
|
private readonly _modelName;
|
|
13
|
-
constructor(prisma: PrismaClientWithCustomTransaction, _modelName:
|
|
14
|
+
constructor(prisma: PrismaClientWithCustomTransaction, _modelName: ModelName);
|
|
14
15
|
withTransaction(fn: (prisma: PrismaTransactionalClient) => Promise<any>): Promise<any>;
|
|
15
16
|
protected repository(transactionalClient?: PrismaTransactionalClient): import(".prisma/client").Prisma.TestDelegate<import("@prisma/client/runtime/library").DefaultArgs>;
|
|
16
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, InjectionToken, Type } from '@nestjs/common';
|
|
2
2
|
import { RepositoryBase } from '../core/database/repository.base';
|
|
3
|
+
export declare const PRISMA_TOKEN = "PRISMA_SERVICE_TOKEN";
|
|
3
4
|
export interface KoalaNestDatabaseRepositoryConfig {
|
|
4
5
|
interface: InjectionToken;
|
|
5
6
|
class: Type<RepositoryBase<any>>;
|
|
@@ -7,10 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
var KoalaNestDatabaseModule_1;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.KoalaNestDatabaseModule = void 0;
|
|
10
|
+
exports.KoalaNestDatabaseModule = exports.PRISMA_TOKEN = void 0;
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
12
|
const env_service_1 = require("../services/env/env.service");
|
|
13
13
|
const prisma_service_1 = require("../services/prisma/prisma.service");
|
|
14
|
+
exports.PRISMA_TOKEN = 'PRISMA_SERVICE_TOKEN';
|
|
14
15
|
let KoalaNestDatabaseModule = exports.KoalaNestDatabaseModule = KoalaNestDatabaseModule_1 = class KoalaNestDatabaseModule {
|
|
15
16
|
static forRoot(config) {
|
|
16
17
|
return {
|
|
@@ -27,11 +28,11 @@ exports.KoalaNestDatabaseModule = KoalaNestDatabaseModule = KoalaNestDatabaseMod
|
|
|
27
28
|
(0, common_1.Module)({
|
|
28
29
|
providers: [
|
|
29
30
|
{
|
|
30
|
-
provide:
|
|
31
|
+
provide: exports.PRISMA_TOKEN,
|
|
31
32
|
useClass: prisma_service_1.PrismaService,
|
|
32
33
|
},
|
|
33
34
|
env_service_1.EnvService,
|
|
34
35
|
],
|
|
35
|
-
exports: [
|
|
36
|
+
exports: [exports.PRISMA_TOKEN],
|
|
36
37
|
})
|
|
37
38
|
], KoalaNestDatabaseModule);
|