@@ -14,6 +14,7 @@ import type {
1414 FindOptions ,
1515 SaveData ,
1616 SingleSaveData ,
17+ ArraySaveData ,
1718 Logger ,
1819} from "@techmmunity/symbiosis" ;
1920import { BaseRepository , SymbiosisError } from "@techmmunity/symbiosis" ;
@@ -27,6 +28,17 @@ import { upsert } from "./upsert";
2728import { handleDatabaseError } from "../utils/handle-database-error" ;
2829
2930import type { ExtraMetadata } from "../types/extra-metadata" ;
31+ import type { CountOutput } from "../types/methods-outputs/count" ;
32+ import type { DeleteOutput } from "../types/methods-outputs/delete" ;
33+ import type { FindOutput } from "../types/methods-outputs/find" ;
34+ import type { FindOneOutput } from "../types/methods-outputs/find-one" ;
35+ import type { InsertOutput } from "../types/methods-outputs/insert" ;
36+ import type { PerformativeCountOutput } from "../types/methods-outputs/performative-count" ;
37+ import type { RecoverOutput } from "../types/methods-outputs/recover" ;
38+ import type { SaveOutput } from "../types/methods-outputs/save" ;
39+ import type { SoftDeleteOutput } from "../types/methods-outputs/soft-delete" ;
40+ import type { UpdateOutput } from "../types/methods-outputs/update" ;
41+ import type { UpsertOutput } from "../types/methods-outputs/upsert" ;
3042
3143export class Repository < Entity > extends BaseRepository < Entity , ExtraMetadata > {
3244 public constructor (
@@ -54,10 +66,18 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
5466 * @param options Options for this operation
5567 * @returns The entity as it's saved on the database
5668 */
57- public save < Result = Array < Entity > | Entity > (
69+ public save (
70+ data : SingleSaveData < Entity > ,
71+ options ?: BaseQueryOptions ,
72+ ) : Promise < SaveOutput < Entity > > ;
73+ public save (
74+ data : ArraySaveData < Entity > ,
75+ options ?: BaseQueryOptions ,
76+ ) : Promise < SaveOutput < Array < Entity > > > ;
77+ public save (
5878 data : SaveData < Entity > ,
5979 options ?: BaseQueryOptions ,
60- ) : Promise < Result > {
80+ ) : Promise < SaveOutput < Array < Entity > | Entity > > {
6181 return save ( this as any , {
6282 data,
6383 options,
@@ -69,10 +89,18 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
6989 /**
7090 * ## NOT IMPLEMENTED!
7191 */
72- public insert < Result = Array < Entity > | Entity > (
92+ public insert (
93+ data : SingleSaveData < Entity > ,
94+ options ?: BaseQueryOptions ,
95+ ) : Promise < InsertOutput < Entity > > ;
96+ public insert (
97+ data : ArraySaveData < Entity > ,
98+ options ?: BaseQueryOptions ,
99+ ) : Promise < InsertOutput < Array < Entity > > > ;
100+ public insert (
73101 _data : SaveData < Entity > ,
74102 _options ?: BaseQueryOptions ,
75- ) : Promise < Result > {
103+ ) : Promise < InsertOutput < Array < Entity > | Entity > > {
76104 // Delete this after the method is implemented
77105 throw new SymbiosisError ( {
78106 code : "NOT_IMPLEMENTED" ,
@@ -109,11 +137,11 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
109137 /**
110138 * ## NOT IMPLEMENTED!
111139 */
112- public update < Result = Array < Entity > | Entity > (
140+ public update (
113141 _conditions : FindConditions < Entity > ,
114142 _data : SingleSaveData < Entity > ,
115143 _options ?: BaseQueryOptions ,
116- ) : Promise < Result > {
144+ ) : Promise < UpdateOutput < Entity > > {
117145 // Delete this after the method is implemented
118146 throw new SymbiosisError ( {
119147 code : "NOT_IMPLEMENTED" ,
@@ -157,11 +185,11 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
157185 * @param options Options for this operation
158186 * @returns The updated record
159187 */
160- public upsert < Result = Array < Entity > | Entity > (
188+ public upsert (
161189 conditions : FindConditions < Entity > ,
162190 data : SingleSaveData < Entity > ,
163191 options ?: BaseQueryOptions ,
164- ) : Promise < Result > {
192+ ) : Promise < UpsertOutput < Entity > > {
165193 return upsert ( this as any , {
166194 conditions,
167195 data,
@@ -174,7 +202,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
174202 public find (
175203 conditions : FindOptions < Entity > ,
176204 options ?: BaseQueryOptions ,
177- ) : Promise < Array < Entity > > {
205+ ) : Promise < FindOutput < Entity > > {
178206 return find ( this as any , {
179207 conditions,
180208 options,
@@ -186,7 +214,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
186214 public findOne (
187215 conditions : FindOneOptions < Entity > ,
188216 options ?: BaseQueryOptions ,
189- ) : Promise < Entity > {
217+ ) : Promise < FindOneOutput < Entity > > {
190218 return findOne ( this as any , {
191219 conditions,
192220 options,
@@ -207,7 +235,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
207235 public delete (
208236 where : FindConditions < Entity > ,
209237 options ?: BaseQueryOptions ,
210- ) : Promise < number > {
238+ ) : Promise < DeleteOutput > {
211239 return del ( this as any , {
212240 where,
213241 options,
@@ -222,7 +250,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
222250 public softDelete (
223251 _where : FindConditions < Entity > ,
224252 _options ?: BaseQueryOptions ,
225- ) : Promise < number > {
253+ ) : Promise < SoftDeleteOutput > {
226254 // Delete this after the method is implemented
227255 throw new SymbiosisError ( {
228256 code : "NOT_IMPLEMENTED" ,
@@ -263,7 +291,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
263291 public recover (
264292 _where : FindConditions < Entity > ,
265293 _options ?: BaseQueryOptions ,
266- ) : Promise < number > {
294+ ) : Promise < RecoverOutput > {
267295 // Delete this after the method is implemented
268296 throw new SymbiosisError ( {
269297 code : "NOT_IMPLEMENTED" ,
@@ -304,7 +332,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
304332 public count (
305333 _where : FindConditions < Entity > ,
306334 _options ?: BaseQueryOptions ,
307- ) : Promise < number > {
335+ ) : Promise < CountOutput > {
308336 // Delete this after the method is implemented
309337 throw new SymbiosisError ( {
310338 code : "NOT_IMPLEMENTED" ,
@@ -345,7 +373,7 @@ export class Repository<Entity> extends BaseRepository<Entity, ExtraMetadata> {
345373 public performativeCount (
346374 _where : FindConditions < Entity > ,
347375 _options ?: BaseQueryOptions ,
348- ) : Promise < number > {
376+ ) : Promise < PerformativeCountOutput > {
349377 // Delete this after the method is implemented
350378 throw new SymbiosisError ( {
351379 code : "NOT_IMPLEMENTED" ,
0 commit comments