SurrealDB Docs Logo

Enter a search query

.let()

Assigns a value as a variable for this connection.

Method Syntax
db.let(key, value)

Arguments

ArgumentsDescription
key required

Specifies the name of the variable.

value required

Assigns the value to the variable name.

Example Usage

# Assign the variable on the connection await db.let('name', { "first": 'Tobie', "last": 'Morgan Hitchcock', }) # Use the variable in a subsequent query await db.query('CREATE person SET name = $name') # Use the variable in a subsequent query await db.query('SELECT * FROM person WHERE name.first = $name.first')

You can remove the variable from the connection using the unset() method.