Optional Functions

Optional Functions

isPresent

available since: 1.0.0

Takes an arbitrary value that could be null and returns whether it is.

bool

Example:

Query:
e.data(d.list(d.expr(e.isPresent(d.string("foo"))), d.expr(e.isPresent(d.null()))))
Result:
[ true, false ]

presentOrZero

available since: 1.0.0

Takes an arbitrary value that could be null and returns its zero value in case it is null.

T

Example:

Query:
e.create(e.tag(d.string("_model")), f.function(["_ref_0"], e.data(m.optional(m.string()))))
Result:
[ "gakUZPvNLAeYKvIb", "nWVgorGwDDYPlOyA" ]

Example:

Query:
e.data(d.struct({
  • valueA: d.expr(e.presentOrZero(e.get({
    • scope: "recordA",
    }
    )
    )
    )
    ,
  • valueB: d.expr(e.presentOrZero(e.get({
    • scope: "recordB",
    }
    )
    )
    )
    ,
}
)
)
Result:
{ "valueA": "test", "valueB": "" }