Skip to content

Commit

Permalink
Merge pull request #148 from pluginpal/feature/document-service
Browse files Browse the repository at this point in the history
refactor: replace the entity service with the document service
  • Loading branch information
boazpoolman authored Oct 12, 2024
2 parents 4f0cecc + fff5a76 commit 79a4a0b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/utils/queryFallBack.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 79a4a0b

Please sign in to comment.