Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-05-2019 02:09 AM
I can use
SET node.timestamp = datetime($properties.timestamp)
To set a temporal type on a node
But, in general, I am setting lots of properties on the node. Before temporal types came along I was able to do:
SET node += $properties
or
CREATE (node:Type $properties)
How can I modify the $properties object in advance in order to set some temporal types and maintain the same (or very similar) cypher queries. Using the javascript bolt client
02-05-2019 07:37 AM
A datetime is a special cypher type. The Neo4j JS driver allows you to create instances of those here:
Have you tried creating instances like this and putting them in your maps and then sending those property maps to the server? What specific error do you get if you do?
02-05-2019 08:00 AM
I was looking into that, but if that behaviour is supported, it's not documented:
Even if it works, I'm reluctant to use an undocumented feature
02-05-2019 10:04 AM
If you don't want to use the driver types for this, you could modify the properties
object in Cypher.
For example, if your properties
param object looks like this:
{dateOfBirth: "2015-03-24", name: "Bob"}'
Then you could use the date
(or datetime
, etc) function to cast dateOfBirth
to a date type:
WITH $properties AS properties
WITH properties {.*, dateOfBirth: date(properties.dateOfBirth)} AS properties
CREATE (p:Person) SET p=properties
02-05-2019 01:22 PM
Using the driver types actually works very nicely. I just wish it was documented that this behaviour is supported . Where should I raise that the documentation on parameters needs updating?
02-05-2019 03:03 PM
Ah gotcha. I've raised this internally to add to the docs.
All the sessions of the conference are now available online