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 2dee1d6cff
commit d7ef5e606c
2 changed files with 11 additions and 2 deletions

View File

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

View File

@ -119,8 +119,16 @@ exports.destroy = async function (ctx) {
const db = new CouchDB(ctx.appId) const db = new CouchDB(ctx.appId)
// Delete all queries for the datasource // Delete all queries for the datasource
const rows = await db.allDocs(getQueryParams(ctx.params.datasourceId, null)) const queries = await db.allDocs(
await db.bulkDocs(rows.rows.map(row => ({ ...row.doc, _deleted: true }))) getQueryParams(ctx.params.datasourceId, null)
)
await db.bulkDocs(
queries.rows.map(row => ({
_id: row.id,
_rev: row.value.rev,
_deleted: true,
}))
)
// delete the datasource // delete the datasource
await db.remove(ctx.params.datasourceId, ctx.params.revId) await db.remove(ctx.params.datasourceId, ctx.params.revId)