Commit 606fb821 authored by nanahira's avatar nanahira

fix

parent 0d7b0aaa
Pipeline #7156 passed with stages
in 1 minute and 20 seconds
......@@ -40,7 +40,10 @@ export class CrudBase<
this.entityName = entityClass.name;
}
async create(ent: T) {
async create(
ent: T,
beforeCreate?: (repo: Repository<T>) => void,
): Promise<void> {
const savedEnt = await this.repo.manager.transaction(async (mdb) => {
const repo = mdb.getRepository(this.entityClass);
if (ent.id != null) {
......@@ -60,6 +63,9 @@ export class CrudBase<
}
}
}
if (beforeCreate) {
await beforeCreate(repo);
}
try {
return await repo.save(ent);
} catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment