neo4j-javascript-driver icon indicating copy to clipboard operation
neo4j-javascript-driver copied to clipboard

DateTime and other constructors to support contracts

Open yurkimus opened this issue 5 months ago • 1 comments

Feature Request

Ability to do:

new DateTime({ ... })

new DateTime(new DateTime(...))

As far as JS is dynamic and relies mostly on object's shapes, which is working overall in the language e.g.: Promise, URL, Response etc. that would be great to see the same possibility in the driver which is supposed to be used with JS.

I may utilise driver's core in places I want to transform it's output, for example datetime(), instead of manually mapping all the properties to the Date object.

Pitch

  • Less code to write
  • Less code to read
  • Less code to maintain on dev-end
  • This is nature of ecmascript
  • Easy to overload both actual function body and typescript definitions
  • Take a look at the following:
  new Intl.DateTime('en').format(new DateTime(node.createdAt).toStandardDate())

yurkimus avatar Jun 21 '25 02:06 yurkimus