From 9cb35c0a30d6a1f359b6524865d3f07fee9f0eb4 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Tue, 24 Sep 2024 10:00:14 +0200 Subject: [PATCH] fix: use existing transaction to batch insert (#21404) --- .../document-service/utils/unidirectional-relations.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/core/src/services/document-service/utils/unidirectional-relations.ts b/packages/core/core/src/services/document-service/utils/unidirectional-relations.ts index 6210b4bfe1..cec816d624 100644 --- a/packages/core/core/src/services/document-service/utils/unidirectional-relations.ts +++ b/packages/core/core/src/services/document-service/utils/unidirectional-relations.ts @@ -86,8 +86,6 @@ const sync = async ( ); await strapi.db.transaction(async ({ trx }) => { - const con = strapi.db.getConnection(); - // Iterate old relations that are deleted and insert the new ones for (const { joinTable, relations } of oldRelations) { // Update old ids with the new ones @@ -98,7 +96,7 @@ const sync = async ( }); // Insert those relations into the join table - await con.batchInsert(joinTable.name, newRelations).transacting(trx); + await trx.batchInsert(joinTable.name, newRelations, 1000); } }); };