Skip to content

Scripting

Arguments

Additional arguments can be passed in to the function from SurrealDB. These are accessible as an array using the arguments object within the JavaScript function.

-- Create a new parameter
LET $val = "SurrealDB";
-- Create a new parameter
LET $words = ["awesome", "advanced", "cool"];
-- Pass the parameter values into the function
CREATE article SET summary = function($val, $words) {
	const [val, words] = arguments;
	return `${val} is ${words.join(', ')}`;
};
Output
[
	{
		id: article:k59tbq3ivsdaf9nzryf5,
		summary: 'SurrealDB is awesome, advanced, cool'
	}
]

Was this page helpful?