♻️ back: repository remove returns success now and file path alternative
This commit is contained in:
committed by
Anton Shepilov
parent
8efcb2546c
commit
c4d45412fd
+1
-1
@@ -291,7 +291,7 @@ export class MongoConnector extends AbstractConnector<MongoConnectionOptions> {
|
||||
});
|
||||
|
||||
Promise.all(promises).then(results => {
|
||||
resolve(results.map(result => result.acknowledged));
|
||||
resolve(results.map(result => result.acknowledged && result.deletedCount == 1));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export default class EntityManager<EntityType extends Record<string, any>> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public async remove(entity: EntityType, entityType?: EntityType): Promise<this> {
|
||||
public async remove(entity: EntityType, entityType?: EntityType): Promise<boolean> {
|
||||
if (entityType) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
entity = _.merge(new (entityType as any)(), entity);
|
||||
@@ -79,12 +79,12 @@ export default class EntityManager<EntityType extends Record<string, any>> {
|
||||
throw Error("Cannot remove this object: it is not an entity.");
|
||||
}
|
||||
|
||||
await this.connector.remove([entity]);
|
||||
const result = await this.connector.remove([entity]);
|
||||
|
||||
localEventBus.publish("database:entities:removed", {
|
||||
entities: [entity],
|
||||
} as DatabaseEntitiesRemovedEvent);
|
||||
|
||||
return this;
|
||||
return result[0];
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -149,8 +149,8 @@ export default class Repository<EntityType> {
|
||||
await Promise.all(entities.map(entity => this.manager.persist(entity)));
|
||||
}
|
||||
|
||||
async remove(entity: EntityType, _context?: ExecutionContext): Promise<void> {
|
||||
await this.manager.remove(entity);
|
||||
async remove(entity: EntityType, _context?: ExecutionContext): Promise<boolean> {
|
||||
return this.manager.remove(entity);
|
||||
}
|
||||
|
||||
//Avoid using this except when no choice
|
||||
|
||||
Reference in New Issue
Block a user