The Mojo SDK ships a set of fluent builders that construct SurrealQL statements for you. Each builder is Copyable and Movable, so you can chain calls or pass it around, and each has a build() method that returns the statement as a string.
query_select() runs a SelectBuilder. The generic query_builder() runs any builder via its build() output.
Available builders
The client exposes a factory method for each builder.
| Builder | Factory | Methods |
|---|---|---|
SelectBuilder | select_builder(target) | fields, where_clause, order_by, limit, start, fetch |
CreateBuilder | create_builder(target) | content, set_field |
UpdateBuilder | update_builder(target) | content, merge, patch, replace, where_clause |
UpsertBuilder | upsert_builder(target) | content, merge |
DeleteBuilder | delete_builder(target) | where_clause |
InsertBuilder | insert_builder(table) | values, relation |
Examples
Build and inspect a statement without running it:
Create a record: