Remove optional chaining from server

This commit is contained in:
Andrew Kingston 2021-10-21 10:24:41 +01:00
parent 5caafed0f8
commit 2b7f393626
1 changed files with 10 additions and 8 deletions

View File

@ -266,13 +266,15 @@ exports.checkForViewUpdates = async (db, table, rename, deletedColumns) => {
}
// Update filters if required
view.meta.filters?.forEach(filter => {
if (filter.key === rename.old) {
filter.key = rename.updated
needsUpdated = true
}
})
} else if (deletedColumns?.length) {
if (view.meta.filters) {
view.meta.filters.forEach(filter => {
if (filter.key === rename.old) {
filter.key = rename.updated
needsUpdated = true
}
})
}
} else if (deletedColumns) {
deletedColumns.forEach(column => {
// Remove calculation statement if required
if (view.meta.field === column) {
@ -289,7 +291,7 @@ exports.checkForViewUpdates = async (db, table, rename, deletedColumns) => {
}
// Remove filters referencing deleted field if required
if (view.meta.filters?.length) {
if (view.meta.filters && view.meta.filters.length) {
const initialLength = view.meta.filters.length
view.meta.filters = view.meta.filters.filter(filter => {
return filter.key !== column