diff --git a/packages/builder/src/stores/backend/datasources.js b/packages/builder/src/stores/backend/datasources.js index 91719ae9b7..7810c3a950 100644 --- a/packages/builder/src/stores/backend/datasources.js +++ b/packages/builder/src/stores/backend/datasources.js @@ -95,6 +95,7 @@ export function createDatasourcesStore() { return { list: sources, selected: null } }) + await queries.fetch() return response }, removeSchemaError: () => { diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 643e822a36..009baec9e0 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -119,8 +119,16 @@ exports.destroy = async function (ctx) { const db = new CouchDB(ctx.appId) // Delete all queries for the datasource - const rows = await db.allDocs(getQueryParams(ctx.params.datasourceId, null)) - await db.bulkDocs(rows.rows.map(row => ({ ...row.doc, _deleted: true }))) + const queries = await db.allDocs( + getQueryParams(ctx.params.datasourceId, null) + ) + await db.bulkDocs( + queries.rows.map(row => ({ + _id: row.id, + _rev: row.value.rev, + _deleted: true, + })) + ) // delete the datasource await db.remove(ctx.params.datasourceId, ctx.params.revId)