File tree 1 file changed +6
-15
lines changed
1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -175,14 +175,9 @@ export abstract class SoftCrudRepository<
175
175
[ pk ] : id ,
176
176
} as Condition < T > ;
177
177
}
178
-
179
- //As parent method findById have filter: FilterExcludingWhere<T>
180
- //so we need add check here.
181
- const entityToRemove = await super . findOne ( filter , options ) ;
182
-
183
- if ( entityToRemove ) {
184
- // Now call super
185
- return super . findById ( id , filter , options ) ;
178
+ const entity = await super . findById ( id , filter , options ) ;
179
+ if ( entity && ! entity . deleted ) {
180
+ return entity ;
186
181
} else {
187
182
throw new HttpErrors . NotFound ( ErrorKeys . EntityNotFound ) ;
188
183
}
@@ -194,13 +189,9 @@ export abstract class SoftCrudRepository<
194
189
filter ?: Filter < T > ,
195
190
options ?: Options ,
196
191
) : Promise < T & Relations > {
197
- //As parent method findById have filter: FilterExcludingWhere<T>
198
- //so we need add check here.
199
- const entityToRemove = await super . findOne ( filter , options ) ;
200
-
201
- if ( entityToRemove ) {
202
- // Now call super
203
- return super . findById ( id , filter , options ) ;
192
+ const entity = await super . findById ( id , filter , options ) ;
193
+ if ( entity ) {
194
+ return entity ;
204
195
} else {
205
196
throw new HttpErrors . NotFound ( ErrorKeys . EntityNotFound ) ;
206
197
}
You can’t perform that action at this time.
0 commit comments