@ooneex/typeorm 0.11.0 → 0.12.0
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/dist/shared/chunk-0swb1h0m.js +51 -0
- package/dist/shared/{chunk-xwe8m6av.js.map → chunk-0swb1h0m.js.map} +2 -2
- package/dist/shared/chunk-2wdazj26.js +371 -0
- package/dist/shared/{chunk-5tnqjb3n.js.map → chunk-2wdazj26.js.map} +2 -2
- package/dist/shared/chunk-6m3p1ht9.js +606 -0
- package/dist/shared/{chunk-yrwsqc6r.js.map → chunk-6m3p1ht9.js.map} +2 -2
- package/dist/shared/{chunk-qrs0g3m9.js → chunk-6vmvyg0q.js} +58 -17
- package/dist/shared/{chunk-qrs0g3m9.js.map → chunk-6vmvyg0q.js.map} +2 -2
- package/dist/shared/chunk-bkdccdhn.js +105 -0
- package/dist/shared/{chunk-p22keb3y.js.map → chunk-bkdccdhn.js.map} +2 -2
- package/dist/shared/chunk-chan1evn.js +72 -0
- package/dist/shared/{chunk-xrqhqgen.js.map → chunk-chan1evn.js.map} +2 -2
- package/dist/shared/chunk-cv6xa6qy.js +621 -0
- package/dist/shared/{chunk-t1jad451.js.map → chunk-cv6xa6qy.js.map} +2 -2
- package/dist/shared/chunk-cwxhwya1.js +548 -0
- package/dist/shared/{chunk-x3pmm3na.js.map → chunk-cwxhwya1.js.map} +2 -2
- package/dist/shared/{chunk-qyf32qsz.js → chunk-eets3mef.js} +75 -22
- package/dist/shared/{chunk-qyf32qsz.js.map → chunk-eets3mef.js.map} +2 -2
- package/dist/shared/chunk-efmap3y3.js +345 -0
- package/dist/shared/{chunk-e51ktjsq.js.map → chunk-efmap3y3.js.map} +2 -2
- package/dist/shared/chunk-hkfj9j6w.js +30 -0
- package/dist/shared/{chunk-pbns711f.js.map → chunk-hkfj9j6w.js.map} +2 -2
- package/dist/shared/{chunk-aj0aak90.js → chunk-jap9t59k.js} +52 -14
- package/dist/shared/{chunk-aj0aak90.js.map → chunk-jap9t59k.js.map} +2 -2
- package/dist/shared/chunk-m4mpkr4n.js +34 -0
- package/dist/shared/{chunk-5ybg5hda.js.map → chunk-m4mpkr4n.js.map} +2 -2
- package/dist/shared/chunk-m9wkjs7v.js +639 -0
- package/dist/shared/{chunk-kw4t1san.js.map → chunk-m9wkjs7v.js.map} +2 -2
- package/dist/shared/chunk-mssxq87m.js +195 -0
- package/dist/shared/{chunk-6kdkyjbn.js.map → chunk-mssxq87m.js.map} +2 -2
- package/dist/shared/chunk-p12g6e7b.js +38 -0
- package/dist/shared/{chunk-6jnj2pfx.js.map → chunk-p12g6e7b.js.map} +2 -2
- package/dist/shared/chunk-qbn9p4vj.js +835 -0
- package/dist/shared/{chunk-nfv9ce7v.js.map → chunk-qbn9p4vj.js.map} +2 -2
- package/dist/shared/chunk-r9hsk9fk.js +20 -0
- package/dist/shared/{chunk-59vwmfpm.js.map → chunk-r9hsk9fk.js.map} +1 -1
- package/dist/shared/chunk-sk8z5zmk.js +112 -0
- package/dist/shared/{chunk-x2d798hg.js.map → chunk-sk8z5zmk.js.map} +2 -2
- package/dist/shared/chunk-tqd6ek7s.js +86 -0
- package/dist/shared/{chunk-19qhst35.js.map → chunk-tqd6ek7s.js.map} +2 -2
- package/dist/shared/{chunk-31y260d6.js → chunk-trhrh4e1.js} +89 -24
- package/dist/shared/{chunk-31y260d6.js.map → chunk-trhrh4e1.js.map} +2 -2
- package/dist/shared/chunk-wg7xcq50.js +38 -0
- package/dist/shared/{chunk-t5cy307m.js.map → chunk-wg7xcq50.js.map} +2 -2
- package/dist/shared/{chunk-jr0xys18.js → chunk-yszvxhf3.js} +41 -11
- package/dist/shared/{chunk-jr0xys18.js.map → chunk-yszvxhf3.js.map} +2 -2
- package/dist/src/entities/book/index.js +34 -2
- package/dist/src/entities/book/index.js.map +1 -1
- package/dist/src/entities/common/index.js +26 -2
- package/dist/src/entities/common/index.js.map +1 -1
- package/dist/src/entities/country/index.js +9 -2
- package/dist/src/entities/country/index.js.map +1 -1
- package/dist/src/entities/currency/index.js +9 -2
- package/dist/src/entities/currency/index.js.map +1 -1
- package/dist/src/entities/folder/index.js +394 -2
- package/dist/src/entities/folder/index.js.map +2 -2
- package/dist/src/entities/gamification/flashcard/index.js +26 -2
- package/dist/src/entities/gamification/flashcard/index.js.map +1 -1
- package/dist/src/entities/gamification/index.js +9 -2
- package/dist/src/entities/gamification/index.js.map +1 -1
- package/dist/src/entities/gamification/mcq/index.js +36 -2
- package/dist/src/entities/gamification/mcq/index.js.map +1 -1
- package/dist/src/entities/image/index.js +31 -2
- package/dist/src/entities/image/index.js.map +1 -1
- package/dist/src/entities/medecine/index.js +13 -2
- package/dist/src/entities/medecine/index.js.map +1 -1
- package/dist/src/entities/payment/index.js +23 -2
- package/dist/src/entities/payment/index.js.map +1 -1
- package/dist/src/entities/user/index.js +30 -2
- package/dist/src/entities/user/index.js.map +1 -1
- package/dist/src/entities/video/index.js +34 -2
- package/dist/src/entities/video/index.js.map +1 -1
- package/dist/src/migrations/book/index.js +541 -137
- package/dist/src/migrations/book/index.js.map +2 -2
- package/dist/src/migrations/common/index.js +63 -14
- package/dist/src/migrations/common/index.js.map +2 -2
- package/dist/src/migrations/country/index.js +48 -13
- package/dist/src/migrations/country/index.js.map +2 -2
- package/dist/src/migrations/currency/index.js +50 -14
- package/dist/src/migrations/currency/index.js.map +2 -2
- package/dist/src/migrations/folder/index.js +426 -104
- package/dist/src/migrations/folder/index.js.map +2 -2
- package/dist/src/migrations/gamification/flashcard/index.js +356 -96
- package/dist/src/migrations/gamification/flashcard/index.js.map +2 -2
- package/dist/src/migrations/gamification/index.js +8 -2
- package/dist/src/migrations/gamification/index.js.map +1 -1
- package/dist/src/migrations/gamification/mcq/index.js +553 -139
- package/dist/src/migrations/gamification/mcq/index.js.map +2 -2
- package/dist/src/migrations/image/index.js +353 -85
- package/dist/src/migrations/image/index.js.map +2 -2
- package/dist/src/migrations/medecine/index.js +132 -36
- package/dist/src/migrations/medecine/index.js.map +2 -2
- package/dist/src/migrations/payment/index.js +339 -94
- package/dist/src/migrations/payment/index.js.map +2 -2
- package/dist/src/migrations/user/index.js +331 -39
- package/dist/src/migrations/user/index.js.map +2 -2
- package/dist/src/migrations/video/index.js +345 -17
- package/dist/src/migrations/video/index.js.map +2 -2
- package/dist/src/repositories/book/index.js +997 -2
- package/dist/src/repositories/book/index.js.map +2 -2
- package/dist/src/repositories/common/index.js +439 -2
- package/dist/src/repositories/common/index.js.map +2 -2
- package/dist/src/repositories/country/index.js +89 -2
- package/dist/src/repositories/country/index.js.map +2 -2
- package/dist/src/repositories/currency/index.js +89 -2
- package/dist/src/repositories/currency/index.js.map +2 -2
- package/dist/src/repositories/gamification/flashcard/index.js +632 -2
- package/dist/src/repositories/gamification/flashcard/index.js.map +2 -2
- package/dist/src/repositories/gamification/index.js +160 -2
- package/dist/src/repositories/gamification/index.js.map +2 -2
- package/dist/src/repositories/gamification/mcq/index.js +1017 -2
- package/dist/src/repositories/gamification/mcq/index.js.map +2 -2
- package/dist/src/repositories/image/index.js +800 -2
- package/dist/src/repositories/image/index.js.map +2 -2
- package/dist/src/repositories/medecine/index.js +243 -2
- package/dist/src/repositories/medecine/index.js.map +2 -2
- package/dist/src/repositories/payment/index.js +560 -2
- package/dist/src/repositories/payment/index.js.map +2 -2
- package/dist/src/repositories/user/index.js +999 -2
- package/dist/src/repositories/user/index.js.map +2 -2
- package/dist/src/repositories/video/index.js +975 -2
- package/dist/src/repositories/video/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/chunk-19qhst35.js +0 -5
- package/dist/shared/chunk-59vwmfpm.js +0 -5
- package/dist/shared/chunk-5tnqjb3n.js +0 -5
- package/dist/shared/chunk-5ybg5hda.js +0 -5
- package/dist/shared/chunk-6jnj2pfx.js +0 -5
- package/dist/shared/chunk-6kdkyjbn.js +0 -5
- package/dist/shared/chunk-e51ktjsq.js +0 -5
- package/dist/shared/chunk-kw4t1san.js +0 -5
- package/dist/shared/chunk-nfv9ce7v.js +0 -5
- package/dist/shared/chunk-p22keb3y.js +0 -5
- package/dist/shared/chunk-pbns711f.js +0 -5
- package/dist/shared/chunk-t1jad451.js +0 -5
- package/dist/shared/chunk-t5cy307m.js +0 -5
- package/dist/shared/chunk-x2d798hg.js +0 -5
- package/dist/shared/chunk-x3pmm3na.js +0 -5
- package/dist/shared/chunk-xrqhqgen.js +0 -5
- package/dist/shared/chunk-xwe8m6av.js +0 -5
- package/dist/shared/chunk-yrwsqc6r.js +0 -5
|
@@ -1,4 +1,91 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
CountryEntity
|
|
4
|
+
} from "../../../shared/chunk-hkfj9j6w.js";
|
|
5
|
+
import"../../../shared/chunk-chan1evn.js";
|
|
6
|
+
import {
|
|
7
|
+
__legacyDecorateClassTS,
|
|
8
|
+
__legacyDecorateParamTS,
|
|
9
|
+
__legacyMetadataTS
|
|
10
|
+
} from "../../../shared/chunk-r9hsk9fk.js";
|
|
3
11
|
|
|
4
|
-
|
|
12
|
+
// src/repositories/country/CountryRepository.ts
|
|
13
|
+
import { inject } from "@ooneex/container";
|
|
14
|
+
import { decorator } from "@ooneex/repository";
|
|
15
|
+
class CountryRepository {
|
|
16
|
+
database;
|
|
17
|
+
constructor(database) {
|
|
18
|
+
this.database = database;
|
|
19
|
+
}
|
|
20
|
+
async open() {
|
|
21
|
+
return await this.database.open(CountryEntity);
|
|
22
|
+
}
|
|
23
|
+
async close() {
|
|
24
|
+
await this.database.close();
|
|
25
|
+
}
|
|
26
|
+
async find(criteria) {
|
|
27
|
+
const repository = await this.open();
|
|
28
|
+
const { page = 1, limit = 100, ...rest } = criteria;
|
|
29
|
+
let skip;
|
|
30
|
+
const take = limit === 0 ? 100 : limit;
|
|
31
|
+
if (page && page > 0 && limit && limit > 0) {
|
|
32
|
+
skip = (page - 1) * take;
|
|
33
|
+
}
|
|
34
|
+
const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
|
|
35
|
+
const total = await this.count(rest.where);
|
|
36
|
+
const totalPages = Math.ceil(total / limit);
|
|
37
|
+
return {
|
|
38
|
+
resources: result,
|
|
39
|
+
total,
|
|
40
|
+
totalPages,
|
|
41
|
+
page,
|
|
42
|
+
limit
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async findOne(id) {
|
|
46
|
+
const repository = await this.open();
|
|
47
|
+
return await repository.findOne({
|
|
48
|
+
where: { id }
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async findOneBy(criteria) {
|
|
52
|
+
const repository = await this.open();
|
|
53
|
+
return await repository.findOne({
|
|
54
|
+
where: criteria
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async create(entity, options) {
|
|
58
|
+
const repository = await this.open();
|
|
59
|
+
return await repository.save(entity, options);
|
|
60
|
+
}
|
|
61
|
+
async createMany(entities, options) {
|
|
62
|
+
const repository = await this.open();
|
|
63
|
+
return await repository.save(entities, options);
|
|
64
|
+
}
|
|
65
|
+
async update(entity, options) {
|
|
66
|
+
return await this.create(entity, options);
|
|
67
|
+
}
|
|
68
|
+
async updateMany(entities, options) {
|
|
69
|
+
return await this.createMany(entities, options);
|
|
70
|
+
}
|
|
71
|
+
async delete(criteria) {
|
|
72
|
+
const repository = await this.open();
|
|
73
|
+
return await repository.softDelete(criteria);
|
|
74
|
+
}
|
|
75
|
+
async count(criteria) {
|
|
76
|
+
const repository = await this.open();
|
|
77
|
+
return await repository.count(criteria ? { where: criteria } : {});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
CountryRepository = __legacyDecorateClassTS([
|
|
81
|
+
decorator.repository(),
|
|
82
|
+
__legacyDecorateParamTS(0, inject("database")),
|
|
83
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
84
|
+
typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
|
|
85
|
+
])
|
|
86
|
+
], CountryRepository);
|
|
87
|
+
export {
|
|
88
|
+
CountryRepository
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//# debugId=0B86569EAC5F07DF64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { inject } from \"@ooneex/container\";\nimport type { ITypeormDatabase } from \"@ooneex/database\";\nimport { decorator } from \"@ooneex/repository\";\nimport type { FilterResultType } from \"@ooneex/types\";\nimport type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from \"typeorm\";\nimport { CountryEntity } from \"../../entities/country/CountryEntity\";\n\n@decorator.repository()\nexport class CountryRepository {\n constructor(\n @inject(\"database\")\n private readonly database: ITypeormDatabase,\n ) {}\n\n public async open(): Promise<Repository<CountryEntity>> {\n return await this.database.open(CountryEntity);\n }\n\n public async close(): Promise<void> {\n await this.database.close();\n }\n\n public async find(\n criteria: FindManyOptions<CountryEntity> & { page?: number; limit?: number },\n ): Promise<FilterResultType<CountryEntity>> {\n const repository = await this.open();\n\n const { page = 1, limit = 100, ...rest } = criteria;\n\n let skip: number | undefined;\n const take = limit === 0 ? 100 : limit;\n\n if (page && page > 0 && limit && limit > 0) {\n skip = (page - 1) * take;\n }\n\n const result = await repository.find({ ...rest, take, ...(skip !== undefined && { skip }) });\n\n const total = await this.count(rest.where);\n const totalPages = Math.ceil(total / limit);\n\n return {\n resources: result,\n total,\n totalPages,\n page,\n limit,\n };\n }\n\n public async findOne(id: string): Promise<CountryEntity | null> {\n const repository = await this.open();\n\n return await repository.findOne({\n where: { id },\n });\n }\n\n public async findOneBy(criteria: FindOptionsWhere<CountryEntity>): Promise<CountryEntity | null> {\n const repository = await this.open();\n\n return await repository.findOne({\n where: criteria,\n });\n }\n\n public async create(entity: CountryEntity, options?: SaveOptions): Promise<CountryEntity> {\n const repository = await this.open();\n\n return await repository.save(entity, options);\n }\n\n public async createMany(entities: CountryEntity[], options?: SaveOptions): Promise<CountryEntity[]> {\n const repository = await this.open();\n\n return await repository.save(entities, options);\n }\n\n public async update(entity: CountryEntity, options?: SaveOptions): Promise<CountryEntity> {\n return await this.create(entity, options);\n }\n\n public async updateMany(entities: CountryEntity[], options?: SaveOptions): Promise<CountryEntity[]> {\n return await this.createMany(entities, options);\n }\n\n public async delete(\n criteria: FindOptionsWhere<CountryEntity> | FindOptionsWhere<CountryEntity>[],\n ): Promise<UpdateResult> {\n const repository = await this.open();\n\n return await repository.softDelete(criteria);\n }\n\n public async count(criteria?: FindOptionsWhere<CountryEntity> | FindOptionsWhere<CountryEntity>[]): Promise<number> {\n const repository = await this.open();\n\n return await repository.count(criteria ? { where: criteria } : {});\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;AAAA;AAEA;AAMO,MAAM,kBAAkB;AAAA,EAGV;AAAA,EAFnB,WAAW,CAEQ,UACjB;AAAA,IADiB;AAAA;AAAA,OAGN,KAAI,GAAuC;AAAA,IACtD,OAAO,MAAM,KAAK,SAAS,KAAK,aAAa;AAAA;AAAA,OAGlC,MAAK,GAAkB;AAAA,IAClC,MAAM,KAAK,SAAS,MAAM;AAAA;AAAA,OAGf,KAAI,CACf,UAC0C;AAAA,IAC1C,MAAM,aAAa,MAAM,KAAK,KAAK;AAAA,IAEnC,QAAQ,OAAO,GAAG,QAAQ,QAAQ,SAAS;AAAA,IAE3C,IAAI;AAAA,IACJ,MAAM,OAAO,UAAU,IAAI,MAAM;AAAA,IAEjC,IAAI,QAAQ,OAAO,KAAK,SAAS,QAAQ,GAAG;AAAA,MAC1C,QAAQ,OAAO,KAAK;AAAA,IACtB;AAAA,IAEA,MAAM,SAAS,MAAM,WAAW,KAAK,KAAK,MAAM,SAAU,SAAS,aAAa,EAAE,KAAK,EAAG,CAAC;AAAA,IAE3F,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,KAAK;AAAA,IACzC,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK;AAAA,IAE1C,OAAO;AAAA,MACL,WAAW;AAAA,MACX;AA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
|
+
"debugId": "0B86569EAC5F07DF64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,4 +1,91 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
CurrencyEntity
|
|
4
|
+
} from "../../../shared/chunk-wg7xcq50.js";
|
|
5
|
+
import"../../../shared/chunk-chan1evn.js";
|
|
6
|
+
import {
|
|
7
|
+
__legacyDecorateClassTS,
|
|
8
|
+
__legacyDecorateParamTS,
|
|
9
|
+
__legacyMetadataTS
|
|
10
|
+
} from "../../../shared/chunk-r9hsk9fk.js";
|
|
3
11
|
|
|
4
|
-
|
|
12
|
+
// src/repositories/currency/CurrencyRepository.ts
|
|
13
|
+
import { inject } from "@ooneex/container";
|
|
14
|
+
import { decorator } from "@ooneex/repository";
|
|
15
|
+
class CurrencyRepository {
|
|
16
|
+
database;
|
|
17
|
+
constructor(database) {
|
|
18
|
+
this.database = database;
|
|
19
|
+
}
|
|
20
|
+
async open() {
|
|
21
|
+
return await this.database.open(CurrencyEntity);
|
|
22
|
+
}
|
|
23
|
+
async close() {
|
|
24
|
+
await this.database.close();
|
|
25
|
+
}
|
|
26
|
+
async find(criteria) {
|
|
27
|
+
const repository = await this.open();
|
|
28
|
+
const { page = 1, limit = 100, ...rest } = criteria;
|
|
29
|
+
let skip;
|
|
30
|
+
const take = limit === 0 ? 100 : limit;
|
|
31
|
+
if (page && page > 0 && limit && limit > 0) {
|
|
32
|
+
skip = (page - 1) * take;
|
|
33
|
+
}
|
|
34
|
+
const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
|
|
35
|
+
const total = await this.count(rest.where);
|
|
36
|
+
const totalPages = Math.ceil(total / limit);
|
|
37
|
+
return {
|
|
38
|
+
resources: result,
|
|
39
|
+
total,
|
|
40
|
+
totalPages,
|
|
41
|
+
page,
|
|
42
|
+
limit
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async findOne(id) {
|
|
46
|
+
const repository = await this.open();
|
|
47
|
+
return await repository.findOne({
|
|
48
|
+
where: { id }
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async findOneBy(criteria) {
|
|
52
|
+
const repository = await this.open();
|
|
53
|
+
return await repository.findOne({
|
|
54
|
+
where: criteria
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async create(entity, options) {
|
|
58
|
+
const repository = await this.open();
|
|
59
|
+
return await repository.save(entity, options);
|
|
60
|
+
}
|
|
61
|
+
async createMany(entities, options) {
|
|
62
|
+
const repository = await this.open();
|
|
63
|
+
return await repository.save(entities, options);
|
|
64
|
+
}
|
|
65
|
+
async update(entity, options) {
|
|
66
|
+
return await this.create(entity, options);
|
|
67
|
+
}
|
|
68
|
+
async updateMany(entities, options) {
|
|
69
|
+
return await this.createMany(entities, options);
|
|
70
|
+
}
|
|
71
|
+
async delete(criteria) {
|
|
72
|
+
const repository = await this.open();
|
|
73
|
+
return await repository.softDelete(criteria);
|
|
74
|
+
}
|
|
75
|
+
async count(criteria) {
|
|
76
|
+
const repository = await this.open();
|
|
77
|
+
return await repository.count(criteria ? { where: criteria } : {});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
CurrencyRepository = __legacyDecorateClassTS([
|
|
81
|
+
decorator.repository(),
|
|
82
|
+
__legacyDecorateParamTS(0, inject("database")),
|
|
83
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
84
|
+
typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
|
|
85
|
+
])
|
|
86
|
+
], CurrencyRepository);
|
|
87
|
+
export {
|
|
88
|
+
CurrencyRepository
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//# debugId=88FFBD4378DDFB2064756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { inject } from \"@ooneex/container\";\nimport type { ITypeormDatabase } from \"@ooneex/database\";\nimport { decorator } from \"@ooneex/repository\";\nimport type { FilterResultType } from \"@ooneex/types\";\nimport type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from \"typeorm\";\nimport { CurrencyEntity } from \"../../entities/currency/CurrencyEntity\";\n\n@decorator.repository()\nexport class CurrencyRepository {\n constructor(\n @inject(\"database\")\n private readonly database: ITypeormDatabase,\n ) {}\n\n public async open(): Promise<Repository<CurrencyEntity>> {\n return await this.database.open(CurrencyEntity);\n }\n\n public async close(): Promise<void> {\n await this.database.close();\n }\n\n public async find(\n criteria: FindManyOptions<CurrencyEntity> & { page?: number; limit?: number },\n ): Promise<FilterResultType<CurrencyEntity>> {\n const repository = await this.open();\n\n const { page = 1, limit = 100, ...rest } = criteria;\n\n let skip: number | undefined;\n const take = limit === 0 ? 100 : limit;\n\n if (page && page > 0 && limit && limit > 0) {\n skip = (page - 1) * take;\n }\n\n const result = await repository.find({ ...rest, take, ...(skip !== undefined && { skip }) });\n\n const total = await this.count(rest.where);\n const totalPages = Math.ceil(total / limit);\n\n return {\n resources: result,\n total,\n totalPages,\n page,\n limit,\n };\n }\n\n public async findOne(id: string): Promise<CurrencyEntity | null> {\n const repository = await this.open();\n\n return await repository.findOne({\n where: { id },\n });\n }\n\n public async findOneBy(criteria: FindOptionsWhere<CurrencyEntity>): Promise<CurrencyEntity | null> {\n const repository = await this.open();\n\n return await repository.findOne({\n where: criteria,\n });\n }\n\n public async create(entity: CurrencyEntity, options?: SaveOptions): Promise<CurrencyEntity> {\n const repository = await this.open();\n\n return await repository.save(entity, options);\n }\n\n public async createMany(entities: CurrencyEntity[], options?: SaveOptions): Promise<CurrencyEntity[]> {\n const repository = await this.open();\n\n return await repository.save(entities, options);\n }\n\n public async update(entity: CurrencyEntity, options?: SaveOptions): Promise<CurrencyEntity> {\n return await this.create(entity, options);\n }\n\n public async updateMany(entities: CurrencyEntity[], options?: SaveOptions): Promise<CurrencyEntity[]> {\n return await this.createMany(entities, options);\n }\n\n public async delete(\n criteria: FindOptionsWhere<CurrencyEntity> | FindOptionsWhere<CurrencyEntity>[],\n ): Promise<UpdateResult> {\n const repository = await this.open();\n\n return await repository.softDelete(criteria);\n }\n\n public async count(\n criteria?: FindOptionsWhere<CurrencyEntity> | FindOptionsWhere<CurrencyEntity>[],\n ): Promise<number> {\n const repository = await this.open();\n\n return await repository.count(criteria ? { where: criteria } : {});\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;AAAA;AAEA;AAMO,MAAM,mBAAmB;AAAA,EAGX;AAAA,EAFnB,WAAW,CAEQ,UACjB;AAAA,IADiB;AAAA;AAAA,OAGN,KAAI,GAAwC;AAAA,IACvD,OAAO,MAAM,KAAK,SAAS,KAAK,cAAc;AAAA;AAAA,OAGnC,MAAK,GAAkB;AAAA,IAClC,MAAM,KAAK,SAAS,MAAM;AAAA;AAAA,OAGf,KAAI,CACf,UAC2C;AAAA,IAC3C,MAAM,aAAa,MAAM,KAAK,KAAK;AAAA,IAEnC,QAAQ,OAAO,GAAG,QAAQ,QAAQ,SAAS;AAAA,IAE3C,IAAI;AAAA,IACJ,MAAM,OAAO,UAAU,IAAI,MAAM;AAAA,IAEjC,IAAI,QAAQ,OAAO,KAAK,SAAS,QAAQ,GAAG;AAAA,MAC1C,QAAQ,OAAO,KAAK;AAAA,IACtB;AAAA,IAEA,MAAM,SAAS,MAAM,WAAW,KAAK,KAAK,MAAM,SAAU,SAAS,aAAa,EAAE,KAAK,EAAG,CAAC;AAAA,IAE3F,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,KAAK;AAAA,IACzC,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK;AAAA,IAE1C,OAAO;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA;AAAA,OAGW,QAAO,CAAC,IAA4C;AAAA,IAC/D,MAAM,aAAa,MAAM,KAAK,KAAK;AAAA,IAEnC,OAAO,MAAM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