1

I am using neo4j-driver inside node js and so far it worked great! But now I have a Date Stamp, which looks 1634717983 when I try to create a node with date property in neo4j it converts the number to double which looks Double(1.634718e+06). Here is my code

nodes[0].createdAt = 1634717983

const createUserCyper = `
    UNWIND $nodes as node 
    CREATE (a:Node {
      id: node.id, 
      name: node.name, 
      createdAt: datetime({epochSeconds:node.createdAt / 1000, nanosecond: 23}), 
  })`;
  const result = await session.run(
    createUserCyper,
    {nodes},
  );

My question is how should I explain to neo4j not to convert my number ?

Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42
Armen Sanoyan
  • 1,898
  • 2
  • 19
  • 32
  • I think all javascript number values passed as parameters will be treated as Float type. https://github.com/neo4j/neo4j-javascript-driver#numbers-and-the-integer-type – Håkan Löfqvist Oct 20 '21 at 09:13
  • Would it make sense to use the DateTime temporal type instead? https://neo4j.com/docs/api/javascript-driver/4.3/class/lib6/temporal-types.js~DateTime.html – Håkan Löfqvist Oct 20 '21 at 09:14
  • @HåkanLöfqvist I mad it by this. datetime({epochSeconds:toInteger(node.createdAt) / 1000, nanosecond: 23}), but could you provide an example of using DateTime ? Probably it's better solution and can be the answer. – Armen Sanoyan Oct 20 '21 at 11:06

0 Answers0