FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard. For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions. |
Function
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Function( name, [database] )
function( name, [database] )
Function( name )
ScopedFunction( name, database )
Function( name, [database] )
Function( name, [database] )
Function( name, [database] )
Description
The Function
function returns a Reference for the specified
function name
in the specified child database
. If a child database
is not specified, the returned function reference belongs to the current
database.
When a child Also, Go does not support optional function parameters, nor function
overloading. To specify a child |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
String |
The name of a function. |
|
Reference |
Optional - A Reference to a child database. If not specified, the current database is used. A Reference to a child database. Optional - A Reference to a child database. If not specified, the current database is used. Optional - A Reference to a child database. If not specified, the current database is used. Optional - A Reference to a child database. If not specified, the current database is used. Optional - A Reference to a child database. If not specified, the current database is used. Optional - A Reference to a child database. If not specified, the current database is used. |
Returns
A reference to a function with the specified name
, in the specified
child database
(or the current database if database
is not
specified).
Examples
-
The following query gets a reference to the function named
increment
in the current database:Function("increment")
Ref(id=increment, collection=Ref(id=functions))
{increment 0xc00014c090 0xc00014c090 <nil>}
RefV(id = "increment", collection = RefV(id = "functions"))
ref(id = "increment", collection = ref(id = "functions"))
Function("increment")
-
The following query gets a Reference to the function named
increment
in a child database named "child_db":Function("increment", Database("child_db"))
Ref(id=increment, collection=Ref(id=functions), database=Ref(id=child_db, collection=Ref(id=databases)))
{increment 0xc000184180 0xc000184180 0xc0001841e0}
RefV(id = "increment", collection = RefV(id = "functions"), database = RefV(id = "child_db", collection = RefV(id = "databases")))
ref(id = "increment", collection = ref(id = "functions"), database = ref(id = "child_db", collection = ref(id = "databases")))
Function("increment", Database("child_db"))
-
The following query demonstrates how to retrieve the function document by its reference:
{ ref: Function("increment"), ts: 1581379483580000, name: 'increment', body: Query(Lambda("X", Add(Var("X"), 1))) }
{'ref': Ref(id=increment, collection=Ref(id=functions)), 'ts': 1603752408980000, 'name': 'increment', 'body': Query({'api_version': '4', 'lambda': 'X', 'expr': {'add': [{'var': 'X'}, 1]}})}
map[body:{[123 34 97 112 105 95 118 101 114 115 105 111 110 34 58 34 52 34 44 34 108 97 109 98 100 97 34 58 34 88 34 44 34 101 120 112 114 34 58 123 34 97 100 100 34 58 91 123 34 118 97 114 34 58 34 88 34 125 44 49 93 125 125]} name:increment ref:{increment 0xc0001441e0 0xc0001441e0 <nil>} ts:1608756885420000]
ObjectV(ref: RefV(id = "increment", collection = RefV(id = "functions")),ts: LongV(1603756293670000),name: StringV(increment),body: QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr]))
{ref: ref(id = "increment", collection = ref(id = "functions")), ts: 1608756885420000, name: "increment", body: QueryV({api_version=4, lambda=X, expr={add=[{var=X}, 1]}})}
{ ref: Function("increment"), ts: 1624310406060000, name: 'increment', body: Query(Lambda("X", Add(Var("X"), 1))) }
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!