The ALTER FUNCTION statement can be used to modify an existing defined function.
Statement syntax
SurrealQL Syntax
ALTER FUNCTION [IFEXISTS]fn::@name [ ( [$argument: @type, ... ] ) ][->@type | DROP RETURNS ] [{@query ... }] [COMMENT@string | DROPCOMMENT] [PERMISSIONS[NONE | FULL | WHERE@condition]]
Example usage
-- Declare a function DEFINEFUNCTIONfn::get_message($input: any) { $input.message };
-- No `message` field, returns nothing fn::get_message("wrong input");
-- Tighten up the valid input for the function ALTERFUNCTIONfn::get_message($input: { error_code: 200, message: string } | {error_code: 404, message: string} ) { $input.message };
-- Returns an error now fn::get_message("wrong input");