Skip to content

Functions

Zafar Ansari edited this page Sep 6, 2023 · 7 revisions

time::floor

Why does time::floor round down to the previous thursday?

Because the 1970-1-1 is a thursday. This is just how it is implemented. As UnixTime is used. To round to sunday you can do

time::floor(date - 3d, 1w) + 3d

meta::id

SELECT * FROM meta::id(person:tobie);
SELECT meta::id(id) FROM person:tobie;

type::point() function

The type::point() function expects 2 arguments (both floats). If you pass 1 argument, then it returns a NULL value. If you pass 2 arguments, then it converts each of them into a . When converting null to a it is 0.0.

Check if the record Id points to a record in the database that exists

 !!person:john.id

The trick here, is that we use the ! operator twice which will give us back a boolean, and you can directly select properties from a record id. In this case we are selecting the id property, as that always exists on a record.

DEFINE FUNCTION fn::record::exists($id: record) {
    RETURN !!$id.id;
};

Clone this wiki locally