From ad97ba68b004b746d1e78cedc87a2dab9b93d3c5 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 17 Oct 2019 21:45:24 +0200 Subject: Fix compatability to Postgresql databases --- app/Controllers/Http/RecipeController.js | 6 +++--- app/Controllers/Http/ServiceController.js | 8 ++++---- app/Controllers/Http/WorkspaceController.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 880f0c3..6c8aa21 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js @@ -35,7 +35,7 @@ class RecipeController { const customRecipes = customRecipesArray.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...JSON.parse(recipe.data), + ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, })); const recipes = [ @@ -144,7 +144,7 @@ class RecipeController { results = dbResults.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...JSON.parse(recipe.data), + ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, })); } else { let remoteResults = []; @@ -155,7 +155,7 @@ class RecipeController { const localResults = localResultsArray.map((recipe) => ({ id: recipe.recipeId, name: recipe.name, - ...JSON.parse(recipe.data), + ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, })); results = [ diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js index 1dfec49..7162268 100644 --- a/app/Controllers/Http/ServiceController.js +++ b/app/Controllers/Http/ServiceController.js @@ -93,7 +93,7 @@ class ServiceController { spellcheckerLanguage: '', workspaces: [], iconUrl: null, - ...JSON.parse(service.settings), + ...typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings, id: service.serviceId, name: service.name, recipeId: service.recipeId, @@ -138,7 +138,7 @@ class ServiceController { .where('userId', auth.user.id).fetch()).rows[0]; const settings = { - ...JSON.parse(serviceData.settings), + ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, ...data, }; @@ -177,7 +177,7 @@ class ServiceController { .where('userId', auth.user.id).fetch()).rows[0]; const settings = { - ...JSON.parse(serviceData.settings), + ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, order: data[service], }; @@ -205,7 +205,7 @@ class ServiceController { spellcheckerLanguage: '', workspaces: [], iconUrl: null, - ...JSON.parse(service.settings), + ...typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings, id: service.serviceId, name: service.name, recipeId: service.recipeId, diff --git a/app/Controllers/Http/WorkspaceController.js b/app/Controllers/Http/WorkspaceController.js index ecf79af..45ed6cc 100644 --- a/app/Controllers/Http/WorkspaceController.js +++ b/app/Controllers/Http/WorkspaceController.js @@ -168,7 +168,7 @@ class WorkspaceController { id: workspace.workspaceId, name: workspace.name, order: workspace.order, - services: JSON.parse(workspace.services), + ...typeof workspace.services === "string" ? JSON.parse(workspace.services) : workspace.services, userId: auth.user.id, })); } -- cgit v1.2.3-54-g00ecf