default
ReQL command: default
Command syntax
value.default(default_value | function) → any sequence.default(default_value | function) → any
Description
Provide a default value in case of non-existence errors. The default
command evaluates its first argument (the value it’s chained to). If that argument returns nil
or a non-existence error is thrown in evaluation, then default
returns its second argument. The second argument is usually a default value, but it can be a function that returns a value.
Example: Retrieve the titles and authors of the table posts
. In the case where the author field is missing or nil
, we want to retrieve the string