Skip to main content

BREAK statement

The BREAK statement can be used to break out of a loop, like within the FOR statement.

Statement syntax

SurrealQL Syntax
BREAK

Example usage

The following query shows example usage of this statement.

-- Create a person for everyone in the array where the number is lower than or equal to 5
LET $num = [1,2,3,4,5,6,7,8,9];

FOR $thing IN $num {
IF $thing > 5 {
BREAK;

} ELSE IF $thing < 5 {
CREATE type::thing(
'person', $thing
) CONTENT {
name: $thing
};

};

};