pub struct SurrealClient { /* private fields */ }Implementations§
Source§impl SurrealClient
impl SurrealClient
Sourcepub fn new(
engine: Box<dyn Engine>,
namespace: Option<String>,
database: Option<String>,
) -> Self
pub fn new( engine: Box<dyn Engine>, namespace: Option<String>, database: Option<String>, ) -> Self
Create a new SurrealDB instance with the given engine and optional namespace/database
Sourcepub fn with_debug(self, enabled: bool) -> Self
pub fn with_debug(self, enabled: bool) -> Self
Enable debug mode to log queries
Sourcepub async fn let_var(&mut self, key: &str, value: Value) -> Result<()>
pub async fn let_var(&mut self, key: &str, value: Value) -> Result<()>
Set a parameter for the session
Sourcepub async fn create(&self, resource: &str, data: Option<Value>) -> Result<Value>
pub async fn create(&self, resource: &str, data: Option<Value>) -> Result<Value>
Create a record in the database
Sourcepub async fn select_all(&self, table: Table) -> Result<Value>
pub async fn select_all(&self, table: Table) -> Result<Value>
Select all records from a table
Sourcepub async fn select_record(&self, record: RecordId) -> Result<Value>
pub async fn select_record(&self, record: RecordId) -> Result<Value>
Select a specific record by ID
Sourcepub async fn select_range(&self, range: RecordRange) -> Result<Value>
pub async fn select_range(&self, range: RecordRange) -> Result<Value>
Select a range of records
Sourcepub async fn update(&self, resource: &str, data: Option<Value>) -> Result<Value>
pub async fn update(&self, resource: &str, data: Option<Value>) -> Result<Value>
Update records in the database
Sourcepub async fn update_record(
&self,
record: RecordId,
data: Value,
) -> Result<Value>
pub async fn update_record( &self, record: RecordId, data: Value, ) -> Result<Value>
Update a specific record by ID
Sourcepub async fn update_all(&self, table: Table, data: Value) -> Result<Value>
pub async fn update_all(&self, table: Table, data: Value) -> Result<Value>
Update all records in a table
Sourcepub async fn upsert(&self, resource: &str, data: Option<Value>) -> Result<Value>
pub async fn upsert(&self, resource: &str, data: Option<Value>) -> Result<Value>
Upsert (insert or update) records in the database
Sourcepub async fn upsert_record(
&self,
record: RecordId,
data: Value,
) -> Result<Value>
pub async fn upsert_record( &self, record: RecordId, data: Value, ) -> Result<Value>
Upsert a specific record by ID
Sourcepub async fn merge(&self, resource: &str, data: Value) -> Result<Value>
pub async fn merge(&self, resource: &str, data: Value) -> Result<Value>
Merge data into records in the database
Sourcepub async fn merge_record(&self, record: RecordId, data: Value) -> Result<Value>
pub async fn merge_record(&self, record: RecordId, data: Value) -> Result<Value>
Merge data into a specific record by ID
Sourcepub async fn merge_all(&self, table: Table, data: Value) -> Result<Value>
pub async fn merge_all(&self, table: Table, data: Value) -> Result<Value>
Merge data into all records in a table
Sourcepub async fn patch(&self, resource: &str, patches: Vec<Value>) -> Result<Value>
pub async fn patch(&self, resource: &str, patches: Vec<Value>) -> Result<Value>
Apply JSON patches to records Apply patches to records in the database
Sourcepub async fn delete_record(&self, record: RecordId) -> Result<Value>
pub async fn delete_record(&self, record: RecordId) -> Result<Value>
Delete a specific record by ID
Sourcepub async fn delete_all(&self, table: Table) -> Result<Value>
pub async fn delete_all(&self, table: Table) -> Result<Value>
Delete all records from a table
Sourcepub async fn insert(&self, table: &str, data: Value) -> Result<Value>
pub async fn insert(&self, table: &str, data: Value) -> Result<Value>
Insert records into the database Insert data into a table
Sourcepub async fn insert_many(&self, table: Table, data: Vec<Value>) -> Result<Value>
pub async fn insert_many(&self, table: Table, data: Vec<Value>) -> Result<Value>
Insert multiple records
Sourcepub async fn relate(
&self,
from: &str,
relation: &str,
to: &str,
data: Option<Value>,
) -> Result<Value>
pub async fn relate( &self, from: &str, relation: &str, to: &str, data: Option<Value>, ) -> Result<Value>
Create a relation between records
Sourcepub async fn relate_records(
&self,
from: RecordId,
relation: Table,
to: RecordId,
data: Option<Value>,
) -> Result<Value>
pub async fn relate_records( &self, from: RecordId, relation: Table, to: RecordId, data: Option<Value>, ) -> Result<Value>
Create a relation between specific records
Sourcepub async fn run(&self, func: &str, args: Option<Value>) -> Result<Value>
pub async fn run(&self, func: &str, args: Option<Value>) -> Result<Value>
Run a stored function
Sourcepub async fn query(&self, sql: &str, variables: Option<Value>) -> Result<Value>
pub async fn query(&self, sql: &str, variables: Option<Value>) -> Result<Value>
Execute a custom SurrealQL query
Sourcepub async fn import(
&self,
_content: &str,
_username: &str,
_password: &str,
) -> Result<Value>
pub async fn import( &self, _content: &str, _username: &str, _password: &str, ) -> Result<Value>
Import database content (HTTP only)
Sourcepub async fn export(&self, _username: &str, _password: &str) -> Result<String>
pub async fn export(&self, _username: &str, _password: &str) -> Result<String>
Export database content (HTTP only)
Sourcepub async fn import_ml(
&self,
_content: &str,
_username: Option<&str>,
_password: Option<&str>,
) -> Result<Value>
pub async fn import_ml( &self, _content: &str, _username: Option<&str>, _password: Option<&str>, ) -> Result<Value>
Import ML model (HTTP only)