Skip to main content
Version: 1.x

Futures

Futures are values which are only computed when the data is selected and returned to the client. Futures can be stored inside records, to enable dynamic values which are always calculated when queried.

Simple futures

Any value or expression can be used inside a future. This value will be dynamically computed on every access to the record.

CREATE person SET accessed_date = <future> { time::now() };

Futures depending on other fields

Futures can be used to calculate values which dynamically change based on other fields. This value will be dynamically computed, on every access to the record, and will use the other field when it is accessed.

CREATE person SET
birthday = <datetime> "2007-06-22",
can_drive = <future> { time::now() > birthday + 18y }
;

Futures can also dynamically access remote records, perform subqueries, or make use of graph traversal.

CREATE person SET
name = 'Jason',
friends = [person:tobie, person:jaime],
adult_friends = <future> { friends[WHERE age > 18].name }
;

Next steps

You've now seen how to create dynamically computed properties on records, using either simple values, and values which depend on local and remote record fields. Take a look at the next chapter to understand how types can be cast and converted to other types.