• Start

Languages

/

Rust

/

Methods

SDK methods

The SurrealDB SDK for Rust enables simple and advanced querying of a remote or embedded database.

Most methods in the SurrealDB SDK involve either working with or creating an instance of the Surreal struct, which serves as the database client instance for embedded or remote databases.

The table below lists documented methods in alphabetical order (by page name).

Function

Description

db.authenticate()

Authenticates the current connection with a JWT token

db.begin()

Start a session-scoped multi-statement transaction, returning a

Transaction

handle (commit, cancel, query, and CRUD)

db.connect()

Connects to a local or remote database endpoint

db.create()

Creates a record in the database

db.delete()

Deletes all records, or a specific record

db.export()

Exports the database to a file or a live stream of bytes

value.get()

On

Value

(and query results), reads a field on an object or an index in an array

db.health()

Runs a health check to verify the server accepts commands

db.import()

Imports the contents of another database from a file

Surreal::init()

Initializes a non-connected instance of the database client

db.insert()

Inserts one or multiple records or relations in the database

db.invalidate()

Invalidates the authentication for the current connection

Surreal::new()

Initializes a connected instance of the database client

db.query()

Runs a set of SurrealQL statements against the database

db.run()

Runs a SurrealQL function

db.select()

Selects all records in a table, or a specific record

db.select().live()

Performs a LIVE SELECT query on the database

db.set()

Assigns a value as a parameter for this connection

db.signin()

Signs this connection in to a specific authentication scope

db.signup()

Signs this connection up to a specific authentication scope

db.unset()

Removes a parameter for this connection

db.update()

Updates all records in a table, or a specific record

db.upsert()

Upserts all records in a table, or a specific record

db.use_ns().use_db()

Switch to a specific namespace and database

db.use_defaults()

Select the default namespace and database for this connection

db.version()

Returns the current database version

db.wait_for()

Blocks until a connection or database session event (such as

WaitFor::Connection

) is ready

Was this page helpful?