Function()
Learn: User-defined functions (UDFs) |
---|
Dynamically get the Function by name.
Description
The Function()
method gets the name function.
Staged schema
If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.
Examples
Get the function by passing the function name to Function()
:
// Call function named `getOrCreateCart`
Function("getOrCreateCart")
"[function getOrCreateCart]"
To call the function, pass arguments in parentheses:
// Calls the `getOrCreateCart()` function on
// a `Customer` document with an `id` of `111`.
Function("getOrCreateCart")('111')
{
id: "412998994633949261",
coll: Order,
ts: Time("2024-10-28T14:23:03.966Z"),
items: "hdW...",
total: 5392,
status: "cart",
customer: Customer("111"),
createdAt: Time("2024-10-28T14:23:03.795981Z"),
payment: {}
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!