Tips for Dealing with Data
Cheat sheet for Makers 💁♂️
Last updated
Cheat sheet for Makers 💁♂️
Last updated
Don't forget to turn on ✅ option
For instance, if you receive a {{text}}
field (type: string) from a Telegram bot in multiple lines and want to process each line separately, here's how you can do it:
Directual stores array and arrayLink types as strings
map()
reduce()
for calculating averagelodash
)The method (new Date()).toISOString()
returns a JS-date-object with current time. This method is more useful than now
, because we can compose complex JS-expressions in a one step using (new Date()).toISOString()
$D.date.format returns string data, so you can't save the result into a field type of date.
Unix timestamp
format is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC.
You can compose an expression using both $D.date parse and $D.date.format to convert a format date from one to another:
If you want to add minutes/hours/days/weeks to the date, here is the way
You may need to aggregate statistics for the day into a single object (e.g., counting the quantity of orders or users). A straightforward approach is to create an object with an ID in the format of the date of the day. Here's an example expression for generating such a day-unique ID:
Don't forget to Save a link (write a link in the field) to the new object in order to be able to edit it. Note, that if you create an object with ID while there is an object with such an ID, nothing will be broken. You'll just create a link to that existing object.
To solve this, use the getTime()
JS-function, which operates on the Date JS-object and returns Milliseconds since Epoch time. Here are the steps:
Getting a Date JS-object applying new Date('{{date}}')
to the field {{date}}
type of date
Getting the value in milliseconds since Epoch time applying .getTime()
Calculate the difference between two dates in milliseconds
Convert milliseconds into days, dividing the result to (1000*60*60*24)
—1000 milliseconds in a one, second; 60 seconds in a minute; 60 minutes in an hour; and 24 hours in a day
Example of using MomentJS:
Directual JS-engine supports Regex-functions. Here are some widespread examples.
$D.concat
is a specific
$D.splice
is a specific
JS iterators are more applicable in . However, .map
iterator can be useful in regular steps as well. This method adits all the elements of a given array.
JS iterators are more applicable in . However, .reduce
iterator can be useful in regular steps as well.
on _.intersection
Learn more about
You can also for that
N.B Here is a nice article referring to
You can also use MomentJS library. Check out .
Tip: use for composing a correct Regex-expression