Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E651

For the complete documentation index optimized for AI agents, see llms.txt.

Non-Iterable Variable

Erroneous Code Example

This error occurs when you try to use a non-iterable variable in an iteration context.

In this example, the parameter name is not a collection, so it cannot be used in an iteration context.

Query addUser(name: String) =>
    FOR n IN name {
        AddN<User>({name: n})
    }
    RETURN "User added"

Solution

Ensure variables used in iterations are collections or arrays.

Query addUser(names: [String]) =>
    FOR n IN names {
        AddN<User>({name: n})
    }
    RETURN "Users added"