Back to top
Documentation SurrealQL Functions Scripting functions Function arguments

Function arguments

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

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