mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
manual rollback
This commit is contained in:
parent
12f3bb794c
commit
ded213f13f
@ -223,6 +223,7 @@ const createEntityManager = (db) => {
|
|||||||
await trx.commit();
|
await trx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await trx.rollback();
|
await trx.rollback();
|
||||||
|
await this.createQueryBuilder(uid).where({ id }).delete().execute();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +282,11 @@ const createEntityManager = (db) => {
|
|||||||
throw new Error('Update requires a where parameter');
|
throw new Error('Update requires a where parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
const entity = await this.createQueryBuilder(uid).select('id').where(where).first().execute();
|
const entity = await this.createQueryBuilder(uid)
|
||||||
|
.select('*')
|
||||||
|
.where(where)
|
||||||
|
.first()
|
||||||
|
.execute({ mapResults: false });
|
||||||
|
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
return null;
|
return null;
|
||||||
@ -298,10 +303,10 @@ const createEntityManager = (db) => {
|
|||||||
const trx = await strapi.db.transaction();
|
const trx = await strapi.db.transaction();
|
||||||
try {
|
try {
|
||||||
await this.updateRelations(uid, id, data, { transaction: trx });
|
await this.updateRelations(uid, id, data, { transaction: trx });
|
||||||
|
|
||||||
await trx.commit();
|
await trx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await trx.rollback();
|
await trx.rollback();
|
||||||
|
await this.createQueryBuilder(uid).where({ id }).update(entity).execute();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user