Fixing issue where deleted datasources wouldn't clear out queries.

This commit is contained in:
mike12345567 2021-11-11 17:13:35 +00:00
parent 9f4ff190c3
commit 599702bfe9
2 changed files with 11 additions and 2 deletions

View File

@ -95,6 +95,7 @@ export function createDatasourcesStore() {
return { list: sources, selected: null }
})
await queries.fetch()
return response
},
removeSchemaError: () => {

View File

@ -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)