@tstdl/base 0.92.75 → 0.92.76
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.
|
@@ -78,7 +78,8 @@ export declare class EntityRepository<T extends Entity = Entity> implements Reso
|
|
|
78
78
|
deleteManyByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T[]>;
|
|
79
79
|
hardDelete(id: string): Promise<void>;
|
|
80
80
|
tryHardDelete(id: string): Promise<boolean>;
|
|
81
|
-
hardDeleteByQuery(query: Query<T>): Promise<
|
|
81
|
+
hardDeleteByQuery(query: Query<T>): Promise<void>;
|
|
82
|
+
tryHardDeleteByQuery(query: Query<T>): Promise<boolean>;
|
|
82
83
|
hardDeleteMany(ids: string[]): Promise<number>;
|
|
83
84
|
hardDeleteManyByQuery(query: Query<T>): Promise<number>;
|
|
84
85
|
protected convertQuery(query: Query<T>): SQL;
|
package/orm/server/repository.js
CHANGED
|
@@ -359,16 +359,22 @@ let EntityRepository = class EntityRepository {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
async tryHardDelete(id) {
|
|
362
|
-
const result = await this.session
|
|
363
|
-
|
|
362
|
+
const result = await this.session
|
|
363
|
+
.delete(this.table)
|
|
364
|
+
.where(eq(this.table.id, id));
|
|
364
365
|
return isNotNull(result.rowCount) && (result.rowCount > 0);
|
|
365
366
|
}
|
|
366
367
|
async hardDeleteByQuery(query) {
|
|
368
|
+
const result = await this.tryHardDeleteByQuery(query);
|
|
369
|
+
if (!result) {
|
|
370
|
+
throw new NotFoundError(`${this.type.entityName} not found.`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async tryHardDeleteByQuery(query) {
|
|
367
374
|
const idQuery = this.getIdLimitQuery(query);
|
|
368
375
|
const result = await this.session
|
|
369
376
|
.delete(this.table)
|
|
370
377
|
.where(inArray(this.table.id, idQuery));
|
|
371
|
-
console.log({ deleteResult: result });
|
|
372
378
|
return isNotNull(result.rowCount) && (result.rowCount > 0);
|
|
373
379
|
}
|
|
374
380
|
async hardDeleteMany(ids) {
|
|
@@ -376,8 +382,9 @@ let EntityRepository = class EntityRepository {
|
|
|
376
382
|
}
|
|
377
383
|
async hardDeleteManyByQuery(query) {
|
|
378
384
|
const sqlQuery = this.convertQuery(query);
|
|
379
|
-
const result = await this.session
|
|
380
|
-
|
|
385
|
+
const result = await this.session
|
|
386
|
+
.delete(this.table)
|
|
387
|
+
.where(sqlQuery);
|
|
381
388
|
return assertNotNullPass(result.rowCount);
|
|
382
389
|
}
|
|
383
390
|
convertQuery(query) {
|