1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

clean up index on table deletion

This commit is contained in:
Martin McKeaveney 2021-02-09 18:57:32 +00:00
parent e599854b14
commit fb4b371d27
2 changed files with 12 additions and 11 deletions

View file

@ -89,22 +89,14 @@
}
function onChangePrimaryIndex(e) {
const enabled = e.target.checked
if (enabled) {
indexes[0] = field.name
} else {
indexes.shift()
indexes = indexes
}
indexes = e.target.checked ? [field.name] : []
}
function onChangeSecondaryIndex(e) {
const enabled = e.target.checked
if (enabled) {
if (e.target.checked) {
indexes[1] = field.name
} else {
indexes.pop()
indexes = indexes
indexes = indexes.slice(0, 1)
}
}

View file

@ -212,6 +212,15 @@ exports.destroy = async function(ctx) {
// don't remove the table itself until very end
await db.remove(tableToDelete)
// remove table search index
const currentIndexes = await db.getIndexes()
const existingIndex = currentIndexes.indexes.find(
existing => existing.name === `search:${ctx.params.tableId}`
)
if (existingIndex) {
await db.deleteIndex(existingIndex)
}
ctx.eventEmitter &&
ctx.eventEmitter.emitTable(`table:delete`, appId, tableToDelete)
ctx.status = 200