SDK methods
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.
Initialization methods
| Function | Description |
|---|---|
db.connect() | Connects to a local or remote database endpoint |
Surreal::init() | Initializes a non-connected instance of the database client |
Surreal::new() | Initializes a connected instance of the database client |
db.set() | Assigns a value as a parameter for this connection |
db.use_ns().use_db() | Switch to a specific namespace and database |
db.unset() | Removes a parameter for this connection |
Query methods
| Function | Description |
|---|---|
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 |
Mutation methods
| Function | Description |
|---|---|
db.create() | Creates a record in the database |
db.delete() | Deletes all records, or a specific record |
db.insert() | Inserts one or multiple records or relations in the database |
db.update() | Updates all records in a table, or a specific record |
db.upsert() | Upserts all records in a table, or a specific record |
Authentication methods
| Function | Description |
|---|---|
db.authenticate() | Authenticates the current connection with a JWT token |
db.invalidate() | Invalidates the authentication for the current connection |
db.signin() | Signs this connection in to a specific authentication scope |
db.signup() | Signs this connection up to a specific authentication scope |
Data methods
| Function | Description |
|---|---|
db.export() | Exports the database to a file or a live stream of bytes |
db.import() | Imports the contents of another database from a file= |
Other methods
| Function | Description |
|---|---|
db.version() | Returns the current database version |