SurrealDB Docs Logo

Enter a search query

Not function

This function can be used to reverse the truthiness of a value.

FunctionDescription
not()Reverses the truthiness of a value.

not

The not function reverses the truthiness of a value. It is functionally identical to !, the NOT operator.

API DEFINITION
not(any) -> bool
RETURN not("I speak the truth");

false

A value is not truthy if it is NONE, NULL, false, empty, or has a value of 0. As such, all the following return true.

RETURN [
    not(""),
    not(false),
    not([]),
    not({}),
    not(0)
];

Similarly, the function can be used twice to determine whether a value is truthy or not. As each item in the example below is truthy, calling not() twice will return the value true for each.

RETURN [
    not(not("I have value")),
    not(not(true)),
    not(not(["value!"])),
    not(not({i_have: "value"})),
    not(not(100))
];

Doubling the ! operator is functionally identical to the above and is a more commonly seen pattern.

RETURN [
    !!"I have value",
    !!true,
    !!["value!"],
    !!{i_have: "value"},
    !!100
];


On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install