Fix prefix of creating update entry

This commit is contained in:
ShootingStar91
2024-07-11 21:07:18 +03:00
parent e58b47f143
commit 36df47e974
2 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -7,13 +7,13 @@ const getUpdateIdField = (tableName: string) => `${tableName[4]}uid`
export const createUpdateEntry = async (
conn: PoolConnection,
prefix: 's' | 't' | 'l' | 'b',
prefix: 'sau' | 'tau' | 'lau' | 'bau',
coordinator: string,
authorizer: string,
comment: string,
id: string | number
) => {
const table = `now_${prefix}au`
const table = `now_${prefix}`
const idField = getUpdateIdField(table)
const result: object[] = await conn.query(
`INSERT INTO ${NOW_DB_NAME}.${table} (${prefix}_coordinator, ${prefix}_authorizer, ${tableToId[table]}, ${prefix}_date, ${prefix}_comment) VALUES (?, ?, ?, ?, ?) RETURNING ${table}.${idField}`,
+6 -6
View File
@@ -155,18 +155,18 @@ export const write: WriteFunction = async (data, tableName, updateOptions) => {
if (updateOptions) {
const { authorizer, userName } = updateOptions
const tableNameToPrefix = {
now_loc: 'l',
com_species: 's',
now_time_unit: 't',
now_tu_bound: 'b',
} as Record<AllowedTables, 's' | 't' | 'l' | 'b'>
now_loc: 'lau',
com_species: 'sau',
now_time_unit: 'tau',
now_tu_bound: 'bau',
} as Record<AllowedTables, 'sau' | 'tau' | 'lau' | 'bau'>
const prefix = tableNameToPrefix[tableName]
const updateEntry = await createUpdateEntry(
conn,
prefix,
COORDINATOR,
authorizer,
(data[`now_${prefix}au`] as { comment: string }).comment,
(data[`now_${prefix}`] as { comment: string }).comment,
result
)
debugLog(`updateEntry: ${printJSON(updateEntry)}`, true)