[英]Neo4j DateTime ValidationError
I'm trying to update a field with datetime
datatype for Neo4j instance running locally.我正在尝试为本地运行的 Neo4j 实例更新具有
datetime
数据类型的字段。 I'm using neode with NodeJs v12.5.0
and Neo4j Version: 3.5.7
community edition running via docker.我使用neode用的NodeJS
v12.5.0
和Neo4j的Version: 3.5.7
通过搬运工人运行的社区版。
My model snippet:我的模型片段:
module.exports = {
...
"fieldName": "datetime"
...
}
My code snippet:我的代码片段:
...
user.update({
id: 'someid',
fieldName: new Date()
})
...
But joi seems to be throwing this error: Error [ValidationError]: child "fieldName" fails because ["fieldName" must be an instance of "DateTime"]
但是 joi 似乎抛出了这个错误:
Error [ValidationError]: child "fieldName" fails because ["fieldName" must be an instance of "DateTime"]
Any help is appreciated.任何帮助表示赞赏。
It's in the driver try this.它在驱动程序中试试这个。
const neo4j = require('neo4j-driver')
const getDateTime = d => {
return neo4j.default.types.DateTime.fromStandardDate(d); // Example: d = new Date();
}
And use getDateTime function to get Datetime format.并使用 getDateTime 函数获取日期时间格式。
maybe because it should be new Date().也许是因为它应该是 new Date()。 Because it's not actually creating a new instance by calling the constructor and is instead a reference to the constructor.
因为它实际上并不是通过调用构造函数来创建新实例,而是对构造函数的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.