Javascript 在postgresSQL中将时间戳附加到数组时间戳列
在我的Postgres DB中,我想在我的start_timestamps和end_timestamps列中添加一个时间戳,类型为timestamp,不带时区[] 我正在尝试以下方法:Javascript 在postgresSQL中将时间戳附加到数组时间戳列,javascript,arrays,postgresql,Javascript,Arrays,Postgresql,在我的Postgres DB中,我想在我的start_timestamps和end_timestamps列中添加一个时间戳,类型为timestamp,不带时区[] 我正在尝试以下方法: const stmt = `UPDATE position p SET translate_x = $1, translate_y = $2, array_append(start_timestamps, $3), arra
const stmt =
`UPDATE position p
SET translate_x = $1, translate_y = $2,
array_append(start_timestamps, $3),
array_append(end_timestamps, $3),
FROM dining_table dt
WHERE p.dining_table_id = dt.id
AND dt.id = $3
AND p.layout_id = $4`;
const params = [translateX, translateY, addedTableId, layoutId, startTimestamp, endTimestamp];
这给了我一个错误:
错误:在或附近出现语法错误
有没有暗示我做错了什么?谢谢。问题在于,您必须将这些结果分配给以下内容:
array_append(start_timestamps, $3),
array_append(end_timestamps, $3),
也许你是说
start_timestamps = array_append(start_timestamps, $3),
end_timestamps = array_append(end_timestamps, $3),
尝试用start_timestamps=start_timestamps | | |$3替换数组_appendstart_timestamps,$3,对于end_timestamps,也可以这样做。直接链接到: