From fff5a765fe042735f2ac84d1bb815196634a3d61 Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Sat, 12 Oct 2024 22:46:32 +0200 Subject: [PATCH] refactor: replace the entity service with the document service --- server/utils/queryFallBack.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/utils/queryFallBack.js b/server/utils/queryFallBack.js index 1a4a06f..45282f0 100644 --- a/server/utils/queryFallBack.js +++ b/server/utils/queryFallBack.js @@ -1,7 +1,7 @@ const queryFallBack = { create: async (queryString, options) => { try { - const newEntity = await strapi.entityService.create(queryString, options); + const newEntity = await strapi.documents(queryString).create(options); return newEntity; } catch (e) { @@ -11,7 +11,10 @@ const queryFallBack = { update: async (queryString, options) => { try { const entity = await strapi.query(queryString).findOne(options); - const updatedEntity = await strapi.entityService.update(queryString, entity.id, options); + const updatedEntity = await strapi.documents(queryString).update({ + documentId: entity.documentId, + ...options, + }); return updatedEntity; } catch (e) { @@ -21,7 +24,9 @@ const queryFallBack = { delete: async (queryString, options) => { try { const entity = await strapi.query(queryString).findOne(options); - await strapi.entityService.delete(queryString, entity.id); + await strapi.documents(queryString).delete({ + documentId: entity.documentId, + }); } catch (e) { await strapi.query(queryString).delete(options); }