Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Knex和MySQL日期时间字段精度_Mysql_Node.js_Bookshelf.js_Knex.js - Fatal编程技术网

Knex和MySQL日期时间字段精度

Knex和MySQL日期时间字段精度,mysql,node.js,bookshelf.js,knex.js,Mysql,Node.js,Bookshelf.js,Knex.js,在节点应用程序中使用knex时,有没有办法将MySQL datetime列设置为datetime(3)或datetime(6),或者更好地为所有datetime列(包括.timestamps)设置默认值 现在看起来,当我插入数据库并检索时,毫秒被截断了 谢谢 在网上询问了这个确切的情况后,我被指到了处理这个特定情况的功能。因此(例如,在mysql中): 将创建一个名为createdAt的DATETIME列,其小数秒精度高达6。一旦我有机会使用本地代码进行测试,我将更新此答案以确认 更新:这确实像

在节点应用程序中使用knex时,有没有办法将MySQL datetime列设置为datetime(3)或datetime(6),或者更好地为所有datetime列(包括.timestamps)设置默认值

现在看起来,当我插入数据库并检索时,毫秒被截断了


谢谢

在网上询问了这个确切的情况后,我被指到了处理这个特定情况的功能。因此(例如,在mysql中):

将创建一个名为
createdAt
DATETIME
列,其小数秒精度高达6。一旦我有机会使用本地代码进行测试,我将更新此答案以确认


更新:这确实像预期的那样有效。

这正是我所需要的。谢谢我要补充的另一点是,我以前使用的是.timestamps(),但现在切换到:
table.specificType('created_at','DATETIME(3)')table.specificType('updated_at','DATETIME(3)
,它在我的代码库中仍然可以正常工作。
table.specificType('createdAt', 'DATETIME(6)');