jora icon indicating copy to clipboard operation
jora copied to clipboard

is there a way to process fields as date?

Open zaverden opened this issue 3 years ago • 3 comments

I have JSON with fiels of dates (in string format)

[{ "start": "2022-08-09T11:00:32.255Z", "end": "2022-08-09T15:38:00.000Z" }]

in result I want to get duration. something like duration: end.asDate() - start.asDate()

I found that API allows me to write custom methods. but I mostly use jora as part of discovery, and it does not allow to set custom functions

zaverden avatar Aug 10 '22 07:08 zaverden

@zaverden "as part of discovery" means as part of browser's extension JsonDiscovery or Discovery.js itself? In first case, yeah, there is no way at the moment to add a custom method. In second case, you can add custom methods on prepare() handler.

lahmatiy avatar Aug 10 '22 10:08 lahmatiy

unfortunatelly for me, it is JsonDiscovery extension.

@lahmatiy in general what do you think about adding build-in dates support to jora?

I can see at least 3 scenario:

  1. find difference between 2 date fields (end.asDate() - start.asDate())
  2. human readable timestamp representation ({ ts: 1660108462352 } -> ts.asDate())
  3. get elapsed time (now() - lastEvent.asDate())

zaverden avatar Aug 11 '22 04:08 zaverden

@zaverden I see. Well, I'm going to add a wide set of methods (lang extensions maybe) to work with strings, numbers, dates etc. However, there are some issues I need to resolve first. I want to avoid adding the things that will be hard to remove or change in the future (without breaking queries that worked before). So I'm a bit too conservative in this area of changes. Anyway, I'm expecting that this gap will be filled in next 1-2 months.

lahmatiy avatar Aug 11 '22 16:08 lahmatiy