gpt4 book ai didi

timestamp - KnexJS : How do you insert/update a timestamp field with current timestamp?

转载 作者:行者123 更新时间:2023-12-04 22:42:29 28 4
gpt4 key购买 nike

标题基本上说明了一切。

我主要对更新案例感兴趣。假设我们正在尝试更新具有时间戳记字段的记录,并且我们希望将该字段设置为记录更新的时间戳记。有没有办法做到这一点?

最佳答案

经过一些实验,我找到了合适的解决方案。只要不使用多个对象(包括.update(...)),就可以在同一查询上使用多个knex.raw调用,而不会造成任何麻烦。您可以将一个对象样式调用与字段/值样式调用结合使用,例如:

knex('table').update({ x: 1, y: 2 }).update('modified_at', knex.fn.now()).where(...) // and so on.

关于timestamp - KnexJS : How do you insert/update a timestamp field with current timestamp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42307487/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com