From afa3e7914722166d9424371ed181e873d3ef9ba6 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 28 May 2020 10:45:59 +0100 Subject: [PATCH] bugfix: save record not wokring (wrong url) --- .../builder/src/components/database/ModelDataTable/api.js | 6 +++--- .../database/ModelDataTable/modals/CreateEditRecord.svelte | 3 ++- .../src/components/nav/SchemaManagementDrawer.svelte | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/database/ModelDataTable/api.js b/packages/builder/src/components/database/ModelDataTable/api.js index c573814e88..c723676388 100644 --- a/packages/builder/src/components/database/ModelDataTable/api.js +++ b/packages/builder/src/components/database/ModelDataTable/api.js @@ -15,13 +15,13 @@ export async function createDatabase(appname, instanceName) { } export async function deleteRecord(record, instanceId) { - const DELETE_RECORDS_URL = `/api/${instanceId}/records/${record._id}/${record._rev}` + const DELETE_RECORDS_URL = `/api/${instanceId}/${record._modelId}/records/${record._id}/${record._rev}` const response = await api.delete(DELETE_RECORDS_URL) return response } -export async function saveRecord(record, instanceId) { - const SAVE_RECORDS_URL = `/api/${instanceId}/records` +export async function saveRecord(record, instanceId, modelId) { + const SAVE_RECORDS_URL = `/api/${instanceId}/${modelId}/records` const response = await api.post(SAVE_RECORDS_URL, record) return await response.json() diff --git a/packages/builder/src/components/database/ModelDataTable/modals/CreateEditRecord.svelte b/packages/builder/src/components/database/ModelDataTable/modals/CreateEditRecord.svelte index d957a99f02..49749a70a1 100644 --- a/packages/builder/src/components/database/ModelDataTable/modals/CreateEditRecord.svelte +++ b/packages/builder/src/components/database/ModelDataTable/modals/CreateEditRecord.svelte @@ -42,7 +42,8 @@ ...record, modelId: $backendUiStore.selectedModel._id, }, - instanceId + instanceId, + $backendUiStore.selectedModel._id ) if (recordResponse.errors) { errors = recordResponse.errors diff --git a/packages/builder/src/components/nav/SchemaManagementDrawer.svelte b/packages/builder/src/components/nav/SchemaManagementDrawer.svelte index cc9e5d86a7..5fb6ed6c25 100644 --- a/packages/builder/src/components/nav/SchemaManagementDrawer.svelte +++ b/packages/builder/src/components/nav/SchemaManagementDrawer.svelte @@ -46,7 +46,7 @@ function selectModel(model) { backendUiStore.update(state => { state.selectedModel = model - state.selectedView = `all_${model._id}` + state.selectedView = `${model._id}` return state }) }