Neo4j Rest API 日期时间数据类型
我正在使用 neo4j REST API 来创建节点和关系。我参考以下文档。
https://neo4j.com/docs/http-api/3.5/actions/< /a>
我正在处理的节点具有动态属性。因此,我使用以下带有参数的有效负载来创建节点。
{
"statements" : [ {
"statement" : "CREATE (n:Person $props) RETURN n",
"parameters" : {
"props" : {
"name" : "My Node",
"dob" : "datetime('20211229T153000')",
"age": 55,
"awsome": true
}
}
} ]
}
这非常适合字符串、整数、布尔数据类型。但是我需要对“dob”使用日期时间数据类型。如果我在双引号内使用日期时间函数(如上面的示例),neo4j 将其视为字符串值,并且不存储为数据时间数据类型。 有解决办法吗?
I am using neo4j REST API to create nodes and relationships. I refer following documentation.
https://neo4j.com/docs/http-api/3.5/actions/
The nodes that I am dealing with have dynamic properties. Therefore I am using following payload with parameters to create nodes.
{
"statements" : [ {
"statement" : "CREATE (n:Person $props) RETURN n",
"parameters" : {
"props" : {
"name" : "My Node",
"dob" : "datetime('20211229T153000')",
"age": 55,
"awsome": true
}
}
} ]
}
This is perfectly work with String, Integer, Boolean data types. However I need to use datetime data type for "dob" . If I use datetime function within double quotes (as in above example) neo4j treat it as string value and does not store as datatime data type.
Is there a solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将非文字值放入 json 数据(props)中。但是,您可以更改 cypher 语句(创建)以更新节点并将 dob 设置为日期时间字段。但首先您需要将该字符串转换为日期时间。
我将字符“T”替换为空格,以便可以解析它。然后将其转换为纪元秒,以便日期时间能够正确转换它。我在本地 neo4j 中测试了它,所以它也应该适合你。
结果:
You cannot put non-literal values inside the json data (props). However, you can change your cypher statement (create) to update the node and set the dob to a datetime field. But first you need to convert that string into datetime.
I replace the char 'T' into space so that it can be parsed. Then convert it into epoch seconds so that datetime will convert it properly. I tested it in my local neo4j so it should also work for you.
Result: