xcally-nest-library 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -3,13 +3,7 @@ import { PaginateConfig, PaginateQuery, Paginated } from 'nestjs-paginate';
|
|
3
3
|
interface IId {
|
4
4
|
id: number;
|
5
5
|
}
|
6
|
-
|
7
|
-
save<T extends DeepPartial<E>>(entity: T): Promise<E>;
|
8
|
-
update<T extends DeepPartial<E> & IId>(entity: T): Promise<E>;
|
9
|
-
count(options: FindOptionsWhere<E>): Promise<number>;
|
10
|
-
getMany(query: PaginateQuery): Promise<Paginated<E>>;
|
11
|
-
}
|
12
|
-
export declare class GenericRepository<E extends ObjectLiteral> implements IGenericRepository<E> {
|
6
|
+
export declare class GenericRepository<E extends ObjectLiteral> {
|
13
7
|
readonly entityManager: EntityManager;
|
14
8
|
protected repository: Repository<E>;
|
15
9
|
protected paginateConfig: PaginateConfig<E>;
|
@@ -18,5 +12,7 @@ export declare class GenericRepository<E extends ObjectLiteral> implements IGene
|
|
18
12
|
save<T extends DeepPartial<E>>(entity: T): Promise<E>;
|
19
13
|
update<T extends DeepPartial<E> & IId>(dto: T): Promise<E>;
|
20
14
|
count(options: FindOptionsWhere<E>): Promise<number>;
|
15
|
+
findAll(): Promise<E[]>;
|
16
|
+
countAll(): Promise<number>;
|
21
17
|
}
|
22
18
|
export {};
|
@@ -1,19 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
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;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
-
};
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.GenericRepository = void 0;
|
13
4
|
const typeorm_1 = require("typeorm");
|
14
|
-
const common_1 = require("@nestjs/common");
|
15
5
|
const nestjs_paginate_1 = require("nestjs-paginate");
|
16
|
-
|
6
|
+
class GenericRepository {
|
17
7
|
constructor(entityManager, entity, paginateConfig) {
|
18
8
|
this.entityManager = entityManager;
|
19
9
|
this.repository = entityManager.getRepository(entity);
|
@@ -33,16 +23,17 @@ let GenericRepository = class GenericRepository {
|
|
33
23
|
if (!entity) {
|
34
24
|
throw new Error('Entity not found');
|
35
25
|
}
|
36
|
-
|
37
|
-
return Object.assign(entity, entityUpdated);
|
26
|
+
return this.repository.save({ id: entity.id, ...dto });
|
38
27
|
}
|
39
28
|
count(options) {
|
40
29
|
return this.repository.count(options);
|
41
30
|
}
|
42
|
-
|
31
|
+
findAll() {
|
32
|
+
return this.repository.find();
|
33
|
+
}
|
34
|
+
countAll() {
|
35
|
+
return this.repository.count();
|
36
|
+
}
|
37
|
+
}
|
43
38
|
exports.GenericRepository = GenericRepository;
|
44
|
-
exports.GenericRepository = GenericRepository = __decorate([
|
45
|
-
(0, common_1.Injectable)(),
|
46
|
-
__metadata("design:paramtypes", [typeorm_1.EntityManager, Object, Object])
|
47
|
-
], GenericRepository);
|
48
39
|
//# sourceMappingURL=generic.repository.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generic.repository.js","sourceRoot":"","sources":["../../../../src/db/typeorm/generic.repository.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"generic.repository.js","sourceRoot":"","sources":["../../../../src/db/typeorm/generic.repository.ts"],"names":[],"mappings":";;;AAAA,qCAAuH;AACvH,qDAAqF;AASrF,MAAa,iBAAiB;IAG5B,YACW,aAA4B,EACrC,MAAuB,EACvB,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