@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.
Files changed (141) hide show
  1. package/dist/shared/chunk-0swb1h0m.js +51 -0
  2. package/dist/shared/{chunk-xwe8m6av.js.map → chunk-0swb1h0m.js.map} +2 -2
  3. package/dist/shared/chunk-2wdazj26.js +371 -0
  4. package/dist/shared/{chunk-5tnqjb3n.js.map → chunk-2wdazj26.js.map} +2 -2
  5. package/dist/shared/chunk-6m3p1ht9.js +606 -0
  6. package/dist/shared/{chunk-yrwsqc6r.js.map → chunk-6m3p1ht9.js.map} +2 -2
  7. package/dist/shared/{chunk-qrs0g3m9.js → chunk-6vmvyg0q.js} +58 -17
  8. package/dist/shared/{chunk-qrs0g3m9.js.map → chunk-6vmvyg0q.js.map} +2 -2
  9. package/dist/shared/chunk-bkdccdhn.js +105 -0
  10. package/dist/shared/{chunk-p22keb3y.js.map → chunk-bkdccdhn.js.map} +2 -2
  11. package/dist/shared/chunk-chan1evn.js +72 -0
  12. package/dist/shared/{chunk-xrqhqgen.js.map → chunk-chan1evn.js.map} +2 -2
  13. package/dist/shared/chunk-cv6xa6qy.js +621 -0
  14. package/dist/shared/{chunk-t1jad451.js.map → chunk-cv6xa6qy.js.map} +2 -2
  15. package/dist/shared/chunk-cwxhwya1.js +548 -0
  16. package/dist/shared/{chunk-x3pmm3na.js.map → chunk-cwxhwya1.js.map} +2 -2
  17. package/dist/shared/{chunk-qyf32qsz.js → chunk-eets3mef.js} +75 -22
  18. package/dist/shared/{chunk-qyf32qsz.js.map → chunk-eets3mef.js.map} +2 -2
  19. package/dist/shared/chunk-efmap3y3.js +345 -0
  20. package/dist/shared/{chunk-e51ktjsq.js.map → chunk-efmap3y3.js.map} +2 -2
  21. package/dist/shared/chunk-hkfj9j6w.js +30 -0
  22. package/dist/shared/{chunk-pbns711f.js.map → chunk-hkfj9j6w.js.map} +2 -2
  23. package/dist/shared/{chunk-aj0aak90.js → chunk-jap9t59k.js} +52 -14
  24. package/dist/shared/{chunk-aj0aak90.js.map → chunk-jap9t59k.js.map} +2 -2
  25. package/dist/shared/chunk-m4mpkr4n.js +34 -0
  26. package/dist/shared/{chunk-5ybg5hda.js.map → chunk-m4mpkr4n.js.map} +2 -2
  27. package/dist/shared/chunk-m9wkjs7v.js +639 -0
  28. package/dist/shared/{chunk-kw4t1san.js.map → chunk-m9wkjs7v.js.map} +2 -2
  29. package/dist/shared/chunk-mssxq87m.js +195 -0
  30. package/dist/shared/{chunk-6kdkyjbn.js.map → chunk-mssxq87m.js.map} +2 -2
  31. package/dist/shared/chunk-p12g6e7b.js +38 -0
  32. package/dist/shared/{chunk-6jnj2pfx.js.map → chunk-p12g6e7b.js.map} +2 -2
  33. package/dist/shared/chunk-qbn9p4vj.js +835 -0
  34. package/dist/shared/{chunk-nfv9ce7v.js.map → chunk-qbn9p4vj.js.map} +2 -2
  35. package/dist/shared/chunk-r9hsk9fk.js +20 -0
  36. package/dist/shared/{chunk-59vwmfpm.js.map → chunk-r9hsk9fk.js.map} +1 -1
  37. package/dist/shared/chunk-sk8z5zmk.js +112 -0
  38. package/dist/shared/{chunk-x2d798hg.js.map → chunk-sk8z5zmk.js.map} +2 -2
  39. package/dist/shared/chunk-tqd6ek7s.js +86 -0
  40. package/dist/shared/{chunk-19qhst35.js.map → chunk-tqd6ek7s.js.map} +2 -2
  41. package/dist/shared/{chunk-31y260d6.js → chunk-trhrh4e1.js} +89 -24
  42. package/dist/shared/{chunk-31y260d6.js.map → chunk-trhrh4e1.js.map} +2 -2
  43. package/dist/shared/chunk-wg7xcq50.js +38 -0
  44. package/dist/shared/{chunk-t5cy307m.js.map → chunk-wg7xcq50.js.map} +2 -2
  45. package/dist/shared/{chunk-jr0xys18.js → chunk-yszvxhf3.js} +41 -11
  46. package/dist/shared/{chunk-jr0xys18.js.map → chunk-yszvxhf3.js.map} +2 -2
  47. package/dist/src/entities/book/index.js +34 -2
  48. package/dist/src/entities/book/index.js.map +1 -1
  49. package/dist/src/entities/common/index.js +26 -2
  50. package/dist/src/entities/common/index.js.map +1 -1
  51. package/dist/src/entities/country/index.js +9 -2
  52. package/dist/src/entities/country/index.js.map +1 -1
  53. package/dist/src/entities/currency/index.js +9 -2
  54. package/dist/src/entities/currency/index.js.map +1 -1
  55. package/dist/src/entities/folder/index.js +394 -2
  56. package/dist/src/entities/folder/index.js.map +2 -2
  57. package/dist/src/entities/gamification/flashcard/index.js +26 -2
  58. package/dist/src/entities/gamification/flashcard/index.js.map +1 -1
  59. package/dist/src/entities/gamification/index.js +9 -2
  60. package/dist/src/entities/gamification/index.js.map +1 -1
  61. package/dist/src/entities/gamification/mcq/index.js +36 -2
  62. package/dist/src/entities/gamification/mcq/index.js.map +1 -1
  63. package/dist/src/entities/image/index.js +31 -2
  64. package/dist/src/entities/image/index.js.map +1 -1
  65. package/dist/src/entities/medecine/index.js +13 -2
  66. package/dist/src/entities/medecine/index.js.map +1 -1
  67. package/dist/src/entities/payment/index.js +23 -2
  68. package/dist/src/entities/payment/index.js.map +1 -1
  69. package/dist/src/entities/user/index.js +30 -2
  70. package/dist/src/entities/user/index.js.map +1 -1
  71. package/dist/src/entities/video/index.js +34 -2
  72. package/dist/src/entities/video/index.js.map +1 -1
  73. package/dist/src/migrations/book/index.js +541 -137
  74. package/dist/src/migrations/book/index.js.map +2 -2
  75. package/dist/src/migrations/common/index.js +63 -14
  76. package/dist/src/migrations/common/index.js.map +2 -2
  77. package/dist/src/migrations/country/index.js +48 -13
  78. package/dist/src/migrations/country/index.js.map +2 -2
  79. package/dist/src/migrations/currency/index.js +50 -14
  80. package/dist/src/migrations/currency/index.js.map +2 -2
  81. package/dist/src/migrations/folder/index.js +426 -104
  82. package/dist/src/migrations/folder/index.js.map +2 -2
  83. package/dist/src/migrations/gamification/flashcard/index.js +356 -96
  84. package/dist/src/migrations/gamification/flashcard/index.js.map +2 -2
  85. package/dist/src/migrations/gamification/index.js +8 -2
  86. package/dist/src/migrations/gamification/index.js.map +1 -1
  87. package/dist/src/migrations/gamification/mcq/index.js +553 -139
  88. package/dist/src/migrations/gamification/mcq/index.js.map +2 -2
  89. package/dist/src/migrations/image/index.js +353 -85
  90. package/dist/src/migrations/image/index.js.map +2 -2
  91. package/dist/src/migrations/medecine/index.js +132 -36
  92. package/dist/src/migrations/medecine/index.js.map +2 -2
  93. package/dist/src/migrations/payment/index.js +339 -94
  94. package/dist/src/migrations/payment/index.js.map +2 -2
  95. package/dist/src/migrations/user/index.js +331 -39
  96. package/dist/src/migrations/user/index.js.map +2 -2
  97. package/dist/src/migrations/video/index.js +345 -17
  98. package/dist/src/migrations/video/index.js.map +2 -2
  99. package/dist/src/repositories/book/index.js +997 -2
  100. package/dist/src/repositories/book/index.js.map +2 -2
  101. package/dist/src/repositories/common/index.js +439 -2
  102. package/dist/src/repositories/common/index.js.map +2 -2
  103. package/dist/src/repositories/country/index.js +89 -2
  104. package/dist/src/repositories/country/index.js.map +2 -2
  105. package/dist/src/repositories/currency/index.js +89 -2
  106. package/dist/src/repositories/currency/index.js.map +2 -2
  107. package/dist/src/repositories/gamification/flashcard/index.js +632 -2
  108. package/dist/src/repositories/gamification/flashcard/index.js.map +2 -2
  109. package/dist/src/repositories/gamification/index.js +160 -2
  110. package/dist/src/repositories/gamification/index.js.map +2 -2
  111. package/dist/src/repositories/gamification/mcq/index.js +1017 -2
  112. package/dist/src/repositories/gamification/mcq/index.js.map +2 -2
  113. package/dist/src/repositories/image/index.js +800 -2
  114. package/dist/src/repositories/image/index.js.map +2 -2
  115. package/dist/src/repositories/medecine/index.js +243 -2
  116. package/dist/src/repositories/medecine/index.js.map +2 -2
  117. package/dist/src/repositories/payment/index.js +560 -2
  118. package/dist/src/repositories/payment/index.js.map +2 -2
  119. package/dist/src/repositories/user/index.js +999 -2
  120. package/dist/src/repositories/user/index.js.map +2 -2
  121. package/dist/src/repositories/video/index.js +975 -2
  122. package/dist/src/repositories/video/index.js.map +2 -2
  123. package/package.json +1 -1
  124. package/dist/shared/chunk-19qhst35.js +0 -5
  125. package/dist/shared/chunk-59vwmfpm.js +0 -5
  126. package/dist/shared/chunk-5tnqjb3n.js +0 -5
  127. package/dist/shared/chunk-5ybg5hda.js +0 -5
  128. package/dist/shared/chunk-6jnj2pfx.js +0 -5
  129. package/dist/shared/chunk-6kdkyjbn.js +0 -5
  130. package/dist/shared/chunk-e51ktjsq.js +0 -5
  131. package/dist/shared/chunk-kw4t1san.js +0 -5
  132. package/dist/shared/chunk-nfv9ce7v.js +0 -5
  133. package/dist/shared/chunk-p22keb3y.js +0 -5
  134. package/dist/shared/chunk-pbns711f.js +0 -5
  135. package/dist/shared/chunk-t1jad451.js +0 -5
  136. package/dist/shared/chunk-t5cy307m.js +0 -5
  137. package/dist/shared/chunk-x2d798hg.js +0 -5
  138. package/dist/shared/chunk-x3pmm3na.js +0 -5
  139. package/dist/shared/chunk-xrqhqgen.js +0 -5
  140. package/dist/shared/chunk-xwe8m6av.js +0 -5
  141. package/dist/shared/chunk-yrwsqc6r.js +0 -5
@@ -1,4 +1,91 @@
1
1
  // @bun
2
- import{z as I}from"../../../shared/chunk-pbns711f.js";import"../../../shared/chunk-xrqhqgen.js";import{Ha as F,Ia as G,Ja as H}from"../../../shared/chunk-59vwmfpm.js";import{inject as L}from"@ooneex/container";import{decorator as M}from"@ooneex/repository";class v{database;constructor(f){this.database=f}async open(){return await this.database.open(I)}async close(){await this.database.close()}async find(f){let x=await this.open(),{page:h=1,limit:q=100,...A}=f,z,B=q===0?100:q;if(h&&h>0&&q&&q>0)z=(h-1)*B;let J=await x.find({...A,take:B,...z!==void 0&&{skip:z}}),D=await this.count(A.where),K=Math.ceil(D/q);return{resources:J,total:D,totalPages:K,page:h,limit:q}}async findOne(f){return await(await this.open()).findOne({where:{id:f}})}async findOneBy(f){return await(await this.open()).findOne({where:f})}async create(f,x){return await(await this.open()).save(f,x)}async createMany(f,x){return await(await this.open()).save(f,x)}async update(f,x){return await this.create(f,x)}async updateMany(f,x){return await this.createMany(f,x)}async delete(f){return await(await this.open()).softDelete(f)}async count(f){return await(await this.open()).count(f?{where:f}:{})}}v=F([M.repository(),G(0,L("database")),H("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],v);export{v as CountryRepository};
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
- //# debugId=EEEBA56481A6F90464756E2164756E21
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": ";uJAAA,yBAAS,kCAET,oBAAS,2BAMF,MAAM,CAAkB,CAGV,SAFnB,WAAW,CAEQ,EACjB,CADiB,qBAGN,KAAI,EAAuC,CACtD,OAAO,MAAM,KAAK,SAAS,KAAK,CAAa,OAGlC,MAAK,EAAkB,CAClC,MAAM,KAAK,SAAS,MAAM,OAGf,KAAI,CACf,EAC0C,CAC1C,IAAM,EAAa,MAAM,KAAK,KAAK,GAE3B,OAAO,EAAG,QAAQ,OAAQ,GAAS,EAEvC,EACE,EAAO,IAAU,EAAI,IAAM,EAEjC,GAAI,GAAQ,EAAO,GAAK,GAAS,EAAQ,EACvC,GAAQ,EAAO,GAAK,EAGtB,IAAM,EAAS,MAAM,EAAW,KA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O,MAAM,WAAW,KAAK,UAAU,OAAO;AAAA;AAAA,OAGnC,OAAM,CAAC,QAAuB,SAA+C;AAAA,IACxF,OAAO,MAAM,KAAK,OAAO,QAAQ,OAAO;AAAA;AAAA,OAG7B,WAAU,CAAC,UAA2B,SAAiD;AAAA,IAClG,OAAO,MAAM,KAAK,WAAW,UAAU,OAAO;AAAA;AAAA,OAGnC,OAAM,CACjB,UACuB;AAAA,IACvB,MAAM,aAAa,MAAM,KAAK,KAAK;AAAA,IAEnC,OAAO,MAAM,WAAW,WAAW,QAAQ;AAAA;AAAA,OAGhC,MAAK,CAAC,UAAiG;AAAA,IAClH,MAAM,aAAa,MAAM,KAAK,KAAK;AAAA,IAEnC,OAAO,MAAM,WAAW,MAAM,WAAW,EAAE,OAAO,SAAS,IAAI,CAAC,CAAC;AAAA;AAErE;AA3Fa,oBAAN;AAAA,EADN,UAAU,WAAW;AAAA,EAGjB,kCAAO,UAAU;AAAA,EAFf;AAAA;AAAA;AAAA,GAAM;",
8
+ "debugId": "0B86569EAC5F07DF64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,91 @@
1
1
  // @bun
2
- import{A as I}from"../../../shared/chunk-t5cy307m.js";import"../../../shared/chunk-xrqhqgen.js";import{Ha as F,Ia as G,Ja as H}from"../../../shared/chunk-59vwmfpm.js";import{inject as L}from"@ooneex/container";import{decorator as M}from"@ooneex/repository";class v{database;constructor(f){this.database=f}async open(){return await this.database.open(I)}async close(){await this.database.close()}async find(f){let x=await this.open(),{page:h=1,limit:q=100,...A}=f,z,B=q===0?100:q;if(h&&h>0&&q&&q>0)z=(h-1)*B;let J=await x.find({...A,take:B,...z!==void 0&&{skip:z}}),D=await this.count(A.where),K=Math.ceil(D/q);return{resources:J,total:D,totalPages:K,page:h,limit:q}}async findOne(f){return await(await this.open()).findOne({where:{id:f}})}async findOneBy(f){return await(await this.open()).findOne({where:f})}async create(f,x){return await(await this.open()).save(f,x)}async createMany(f,x){return await(await this.open()).save(f,x)}async update(f,x){return await this.create(f,x)}async updateMany(f,x){return await this.createMany(f,x)}async delete(f){return await(await this.open()).softDelete(f)}async count(f){return await(await this.open()).count(f?{where:f}:{})}}v=F([M.repository(),G(0,L("database")),H("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],v);export{v as CurrencyRepository};
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
- //# debugId=BB1262F2B0D0F6AC64756E2164756E21
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": ";uJAAA,yBAAS,kCAET,oBAAS,2BAMF,MAAM,CAAmB,CAGX,SAFnB,WAAW,CAEQ,EACjB,CADiB,qBAGN,KAAI,EAAwC,CACvD,OAAO,MAAM,KAAK,SAAS,KAAK,CAAc,OAGnC,MAAK,EAAkB,CAClC,MAAM,KAAK,SAAS,MAAM,OAGf,KAAI,CACf,EAC2C,CAC3C,IAAM,EAAa,MAAM,KAAK,KAAK,GAE3B,OAAO,EAAG,QAAQ,OAAQ,GAAS,EAEvC,EACE,EAAO,IAAU,EA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