import type sqlite from 'better-sqlite3' type RecordTable = | 'BurialSiteStatuses' | 'BurialSiteTypeFields' | 'BurialSiteTypes' | 'CommittalTypes' | 'ContractTypeFields' | 'ContractTypes' | 'FeeCategories' | 'Fees' | 'IntermentContainerTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' const recordIdColumns = new Map([ ['BurialSiteStatuses', 'burialSiteStatusId'], ['BurialSiteTypeFields', 'burialSiteTypeFieldId'], ['BurialSiteTypes', 'burialSiteTypeId'], ['CommittalTypes', 'committalTypeId'], ['ContractTypeFields', 'contractTypeFieldId'], ['ContractTypes', 'contractTypeId'], ['FeeCategories', 'feeCategoryId'], ['Fees', 'feeId'], ['IntermentContainerTypes', 'intermentContainerTypeId'], ['WorkOrderMilestoneTypes', 'workOrderMilestoneTypeId'], ['WorkOrderTypes', 'workOrderTypeId'] ]) export function updateRecordOrderNumber( recordTable: RecordTable, recordId: number | string, orderNumber: number | string, connectedDatabase: sqlite.Database ): boolean { const result = connectedDatabase .prepare( `update ${recordTable} set orderNumber = ? where recordDelete_timeMillis is null and ${recordIdColumns.get(recordTable)} = ?` ) .run(orderNumber, recordId) return result.changes > 0 }