Other Functions
Type checking, type casting, conditional logic, object manipulation, and utility functions.
Type Checking Functions
Functions to check the type of values at runtime.
IS_DATETIME(val)
Returns true if value is an ISO 8601 date string.
RETURN IS_DATETIME("2024-01-15T10:30:00Z") --true
TYPENAME(val)
Returns the type name as a string.
RETURN TYPENAME([1,2]) --"array"
RETURN TYPENAME("hi") --"string"
IS_EMAIL(val)
Returns true if value is a valid email format.
RETURN IS_EMAIL("[email protected]") --true
IS_URL(val)
Returns true if value is a valid URL format.
RETURN IS_URL("https://example.com") --true
IS_UUID(val)
Returns true if value is a valid UUID format.
RETURN IS_UUID("550e8400-e29b-41d4-...") --true
Type Casting Functions
Functions to convert values between different types.
TO_BOOL(value)
Casts value to boolean.
RETURN TO_BOOL(null) --false
RETURN TO_BOOL(1) --true
RETURN TO_BOOL(0) --false
TO_NUMBER(value)
Casts value to number.
RETURN TO_NUMBER("123") --123
RETURN TO_NUMBER(true) --1
RETURN TO_NUMBER("foo") --0
Logical & Conditional
Functions for conditional logic and null handling.
IF(cond, true, false)
Condition evaluation. Returns true_val if cond is true, else false_val.
RETURN IF(1 > 0, "yes", "no") --"yes"
RETURN IF(null, 1, 0) --0
Object Functions
Functions for manipulating objects and documents.
DEEP_MERGE(obj1, obj2, ...)
Deep merge objects recursively.
RETURN DEEP_MERGE({a:{b:1}}, {a:{c:2}})
--{a:{b:1,c:2}}
ATTRIBUTES(doc, removeInternal?, sort?)
Top-level attribute keys of the document.
RETURN ATTRIBUTES(doc, true)
Collection Functions
Usage Example
Get document counts for multiple collections:
RETURN {
users: COLLECTION_COUNT("users"),
orders: COLLECTION_COUNT("orders"),
products: COLLECTION_COUNT("products")
}
Hashing & Encoding
Functions for hashing strings and encoding/decoding data.
Unique ID Generation
Functions for generating unique identifiers for documents and keys.
ID Type Comparison
| Type | Length | Sortable | Best For |
|---|---|---|---|
| UUID v4 | 36 chars | No | General unique identifiers |
| UUID v7 | 36 chars | Yes | Time-ordered records, primary keys |
| ULID | 26 chars | Yes | Compact time-sortable IDs |
| Nano ID | 21 chars | No | URL-safe short IDs, user-facing |