如何在 postgres(pg-promise) 中用当前时间戳更新空时间戳?
How to update the null timestamp with current timestamp in postgres(pg-promise)?
当我尝试更新我的数据库字段时 date_read(D-type = timestamp with time zone) 最初为 null,然后我使用当前时间戳我收到以下错误。
“消息”:“列\“date_read\”是带时区的时间戳类型,但表达式是文本类型”
const object1= Object.keys(req.body)[0]; //oytput = uuid
const upodatedObj = [ { uuid: 123, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” },{ uuid: 124, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” },{ uuid: 125, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” } ]
const cs = new pgp.helpers.ColumnSet([`?${object1}`, “is_read”, “date_read”], {
table: “my-table”,
});
const update =
pgp.helpers.update(upodatedObj, cs) +
`WHERE v.${object1} = t.${object1}`;
await pool.none(update);
但是更新时出现错误。
寻找如何使用当前时间戳(“2021-04-16T11:15:30.658+00Z”)更新 date_read 字段的解决方案。
当我尝试更新我的数据库字段时 date_read(D-type = timestamp with time zone) 最初为 null,然后我使用当前时间戳我收到以下错误。
“消息”:“列\“date_read\”是带时区的时间戳类型,但表达式是文本类型”
const object1= Object.keys(req.body)[0]; //oytput = uuid
const upodatedObj = [ { uuid: 123, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” },{ uuid: 124, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” },{ uuid: 125, data_read: true, date_read: “2021-04-16T11:15:30.658+00Z” } ]
const cs = new pgp.helpers.ColumnSet([`?${object1}`, “is_read”, “date_read”], {
table: “my-table”,
});
const update =
pgp.helpers.update(upodatedObj, cs) +
`WHERE v.${object1} = t.${object1}`;
await pool.none(update);
但是更新时出现错误。 寻找如何使用当前时间戳(“2021-04-16T11:15:30.658+00Z”)更新 date_read 字段的解决方案。