pub struct DatabaseClient { /* private fields */ }Expand description
An ArcadeDbClient bound to one database: every delegated method drops
the database: &str parameter. The connect-time name is the single source
of truth, which removes the per-call-site repetition and the wrong-db
mistake class.
let db = ArcadeDbClient::connect(addr, user, pass, "mydb").await?;
let res = db.query("SELECT FROM item LIMIT 10").await?;Un-delegated methods stay reachable through Deref<Target = ArcadeDbClient> (with the explicit parameter).
Implementations§
Source§impl DatabaseClient
impl DatabaseClient
Sourcepub fn batch(&self) -> Batch
pub fn batch(&self) -> Batch
The multi-statement facade, database-bound (see crate::batch::Batch).
Sourcepub async fn connect(
addr: &str,
username: &str,
password: &str,
database: &str,
) -> Result<Self>
pub async fn connect( addr: &str, username: &str, password: &str, database: &str, ) -> Result<Self>
ArcadeDbClient::connect straight into a bound handle.
Sourcepub async fn query(&self, query: &str) -> Result<QueryResult>
pub async fn query(&self, query: &str) -> Result<QueryResult>
SQL read.
Sourcepub async fn query_with_values(
&self,
query: &str,
parameters: impl Into<Params>,
) -> Result<QueryResult>
pub async fn query_with_values( &self, query: &str, parameters: impl Into<Params>, ) -> Result<QueryResult>
Parameterized SQL read (params! { .. } or a DTO’s to_param_map()).
Sourcepub async fn execute(&self, command: &str) -> Result<ExecuteCommandResponse>
pub async fn execute(&self, command: &str) -> Result<ExecuteCommandResponse>
SQL DDL/DML command.
Sourcepub async fn execute_with_values(
&self,
command: &str,
parameters: impl Into<Params>,
) -> Result<ExecuteCommandResponse>
pub async fn execute_with_values( &self, command: &str, parameters: impl Into<Params>, ) -> Result<ExecuteCommandResponse>
Parameterized SQL command.
Sourcepub async fn stream_query<F>(
&self,
query: &str,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query<F>( &self, query: &str, on_batch: F, ) -> Result<StreamSummary>
Server-streaming SQL read.
Sourcepub async fn stream_query_with_values<F>(
&self,
query: &str,
parameters: impl Into<Params>,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query_with_values<F>( &self, query: &str, parameters: impl Into<Params>, on_batch: F, ) -> Result<StreamSummary>
Parameterized server-streaming SQL read.
Sourcepub async fn lookup_by_rid(&self, rid: &Link) -> Result<Option<GrpcRecord>>
pub async fn lookup_by_rid(&self, rid: &Link) -> Result<Option<GrpcRecord>>
Direct record fetch by rid.
Sourcepub async fn create_record(
&self,
class_name: &str,
props: Vec<(&str, GrpcValue)>,
) -> Result<CreateRecordResponse>
pub async fn create_record( &self, class_name: &str, props: Vec<(&str, GrpcValue)>, ) -> Result<CreateRecordResponse>
Create a record from (property, value) pairs; returns the new rid.
Sourcepub async fn update_record_partial(
&self,
rid: &Link,
props: impl Into<Params>,
) -> Result<bool>
pub async fn update_record_partial( &self, rid: &Link, props: impl Into<Params>, ) -> Result<bool>
Partially update a record by rid.
Sourcepub async fn stream_query_with_options<F>(
&self,
query: &str,
parameters: impl Into<Params>,
options: StreamOptions,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query_with_options<F>( &self, query: &str, parameters: impl Into<Params>, options: StreamOptions, on_batch: F, ) -> Result<StreamSummary>
stream_query_with_values with
explicit execution knobs (bound database).
Sourcepub async fn stream_query_rows<T, F>(
&self,
query: &str,
parameters: impl Into<Params>,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
pub async fn stream_query_rows<T, F>(
&self,
query: &str,
parameters: impl Into<Params>,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
Typed row streaming (bound database) — decoded rows passed to
on_row as they arrive, no result-set buffering.
Sourcepub async fn delete_record(&self, rid: &Link) -> Result<bool>
pub async fn delete_record(&self, rid: &Link) -> Result<bool>
Delete a record by rid.
Sourcepub async fn fetch_optional<T>(
&self,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>
pub async fn fetch_optional<T>( &self, query: &str, parameters: impl Into<Params>, ) -> Result<Option<T>>
Typed fetch of at most one row (bound database).
Sourcepub async fn fetch_one<T>(
&self,
query: &str,
parameters: impl Into<Params>,
) -> Result<T>
pub async fn fetch_one<T>( &self, query: &str, parameters: impl Into<Params>, ) -> Result<T>
Typed one-row fetch (bound database); empty result is
ArcadeDbError::NotFound.
Sourcepub async fn query_scalar<T>(
&self,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>where
T: for<'de> FromGrpcValue<'de>,
pub async fn query_scalar<T>(
&self,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>where
T: for<'de> FromGrpcValue<'de>,
Single-column scalar decode (bound database).
Sourcepub async fn write_returning_optional<T>(
&self,
command: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>
pub async fn write_returning_optional<T>( &self, command: &str, parameters: impl Into<Params>, ) -> Result<Option<T>>
Write command returning the stored row, decoded (bound database);
Ok(None) when the statement matched nothing.
Sourcepub async fn upsert_returning<T>(
&self,
command: &str,
parameters: impl Into<Params>,
) -> Result<T>
pub async fn upsert_returning<T>( &self, command: &str, parameters: impl Into<Params>, ) -> Result<T>
Write command returning the stored row, decoded (bound database).
Sourcepub async fn lookup_by_key<T>(
&self,
type_name: &str,
key: &[(&str, GrpcValue)],
) -> Result<Option<T>>
pub async fn lookup_by_key<T>( &self, type_name: &str, key: &[(&str, GrpcValue)], ) -> Result<Option<T>>
Typed lookup by (composite) key (bound database).
Sourcepub async fn count_type(&self, type_name: &str) -> Result<i64>
pub async fn count_type(&self, type_name: &str) -> Result<i64>
Count all records of a type (bound database).
Sourcepub async fn run_transaction<T, F, Fut>(
&self,
isolation: TransactionIsolation,
retries: u32,
body: F,
) -> Result<T>
pub async fn run_transaction<T, F, Fut>( &self, isolation: TransactionIsolation, retries: u32, body: F, ) -> Result<T>
Retrying transaction closure on the bound database.
Sourcepub async fn bulk_insert(
&self,
target_class: &str,
key_columns: &[&str],
rows: Vec<GrpcRecord>,
) -> Result<InsertSummary>
pub async fn bulk_insert( &self, target_class: &str, key_columns: &[&str], rows: Vec<GrpcRecord>, ) -> Result<InsertSummary>
Idempotent bulk insert (ignore-on-conflict).
Sourcepub async fn bulk_upsert(
&self,
target_class: &str,
key_columns: &[&str],
update_columns_on_conflict: &[&str],
rows: Vec<GrpcRecord>,
) -> Result<InsertSummary>
pub async fn bulk_upsert( &self, target_class: &str, key_columns: &[&str], update_columns_on_conflict: &[&str], rows: Vec<GrpcRecord>, ) -> Result<InsertSummary>
Bulk upsert (update-on-conflict).
Sourcepub async fn bulk_upsert_dtos<T>(
&self,
target_class: &str,
rows: Vec<T>,
) -> Result<InsertSummary>where
T: ToGrpcRecord + Send,
pub async fn bulk_upsert_dtos<T>(
&self,
target_class: &str,
rows: Vec<T>,
) -> Result<InsertSummary>where
T: ToGrpcRecord + Send,
Typed bulk upsert from ToGrpcRecord DTOs.
Sourcepub async fn transaction(
&self,
isolation: TransactionIsolation,
) -> Result<Transaction<'_>>
pub async fn transaction( &self, isolation: TransactionIsolation, ) -> Result<Transaction<'_>>
Begin a drop-safe transaction on the bound database.
Sourcepub async fn execute_language(
&self,
language: &str,
command: &str,
) -> Result<ExecuteCommandResponse>
pub async fn execute_language( &self, language: &str, command: &str, ) -> Result<ExecuteCommandResponse>
Command in an explicit language ("sql", "cypher", …).
Sourcepub async fn cypher_query(&self, query: &str) -> Result<QueryResult>
pub async fn cypher_query(&self, query: &str) -> Result<QueryResult>
Cypher read query.
Sourcepub async fn cypher_execute(
&self,
command: &str,
) -> Result<ExecuteCommandResponse>
pub async fn cypher_execute( &self, command: &str, ) -> Result<ExecuteCommandResponse>
Cypher write command.
Methods from Deref<Target = ArcadeDbClient>§
Sourcepub fn to_database(&self, database: impl Into<String>) -> DatabaseClient
pub fn to_database(&self, database: impl Into<String>) -> DatabaseClient
Bind this client to database, producing a DatabaseClient whose
methods omit the database parameter. Cheap: clones the channel handle.
Sourcepub async fn execute_language(
&self,
database: &str,
language: &str,
command: &str,
) -> Result<ExecuteCommandResponse>
pub async fn execute_language( &self, database: &str, language: &str, command: &str, ) -> Result<ExecuteCommandResponse>
Execute a command in the given query language (“sql” or “cypher”).
Returns the server response including affected records and write stats.
Sourcepub async fn execute(
&self,
database: &str,
command: &str,
) -> Result<ExecuteCommandResponse>
pub async fn execute( &self, database: &str, command: &str, ) -> Result<ExecuteCommandResponse>
Execute a SQL command (DDL, INSERT, UPDATE, DELETE).
Returns the server response including affected records and write stats.
Sourcepub async fn execute_with_values(
&self,
database: &str,
command: &str,
parameters: impl Into<Params>,
) -> Result<ExecuteCommandResponse>
pub async fn execute_with_values( &self, database: &str, command: &str, parameters: impl Into<Params>, ) -> Result<ExecuteCommandResponse>
execute with bound :name parameters — the
command-RPC analogue of query_with_values.
Prefer this whenever the command references caller-supplied values
(user names, urls, ids): no literal escaping, no injection surface.
Build parameter values with Params (e.g. the
params! macro) or a RecordEncode DTO’s
ToGrpcRecord::to_param_map.
Sourcepub async fn cypher_query(
&self,
database: &str,
query: &str,
) -> Result<QueryResult>
pub async fn cypher_query( &self, database: &str, query: &str, ) -> Result<QueryResult>
Execute a Cypher read query (MATCH + RETURN, etc.).
Uses the streaming query RPC with language=“cypher”.
Sourcepub async fn cypher_execute(
&self,
database: &str,
command: &str,
) -> Result<ExecuteCommandResponse>
pub async fn cypher_execute( &self, database: &str, command: &str, ) -> Result<ExecuteCommandResponse>
Execute a Cypher write command (MATCH + SET, etc.).
Uses the execute_command RPC with language set to “opencypher” (the variant that ArcadeDB accepts for write operations).
Sourcepub async fn query(&self, database: &str, query: &str) -> Result<QueryResult>
pub async fn query(&self, database: &str, query: &str) -> Result<QueryResult>
Execute a SQL query and return the result records with server-side timing.
Sourcepub async fn query_with_values(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
) -> Result<QueryResult>
pub async fn query_with_values( &self, database: &str, query: &str, parameters: impl Into<Params>, ) -> Result<QueryResult>
Execute a SQL query with bound parameters (the :name placeholders in
the query are filled from parameters).
Prefer this over query whenever the query references
caller-supplied values — bound params avoid SQL-injection concerns and
let ArcadeDB cache the parsed query plan. The vector-search operators
(vector.sparseNeighbors, vector.fuse, SEARCH_INDEX) in particular
expect array-valued params for the query token/weight vectors.
Build parameter values with Params (e.g. the
params! macro), or assemble list/map values
directly from the proto types re-exported at the crate root.
Sourcepub async fn lookup_by_rid(
&self,
database: &str,
rid: &Link,
) -> Result<Option<GrpcRecord>>
pub async fn lookup_by_rid( &self, database: &str, rid: &Link, ) -> Result<Option<GrpcRecord>>
Fetch one record by rid — the O(1) path: direct bucket/position
dereference, no SQL parsing, no index traversal. The fastest read
ArcadeDB offers; prefer it whenever the caller already holds the
record’s Link (a prior query’s @rid, an edge’s @in/@out —
all record intrinsics).
Durability note: rids are stable for a database’s lifetime but may shift across rebuilds/backup-restores — treat them as within-lifetime handles, never as persisted identifiers. Domain keys (e.g. a UNIQUE index column) remain the durable identity.
Sourcepub async fn lookup<T>(&self, database: &str, rid: &Link) -> Result<Option<T>>
pub async fn lookup<T>(&self, database: &str, rid: &Link) -> Result<Option<T>>
lookup_by_rid decoded into an owned DTO
(T: TryFrom<&GrpcRecord>, i.e. an owned RecordDecode struct).
Sourcepub async fn fetch_optional<T>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>
pub async fn fetch_optional<T>( &self, database: &str, query: &str, parameters: impl Into<Params>, ) -> Result<Option<T>>
Typed fetch of at most one row: Ok(None) on an empty result, a
decode error only when a row exists but does not match T.
Pair point-lookups with LIMIT 1 — the call decodes the first
row but the RPC still materializes the whole result set.
Sourcepub async fn fetch_one<T>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
) -> Result<T>
pub async fn fetch_one<T>( &self, database: &str, query: &str, parameters: impl Into<Params>, ) -> Result<T>
fetch_optional with a one-row contract: an
empty result is ArcadeDbError::NotFound, not Ok(None).
Same wire-cost note: keep the query itself to one row (LIMIT 1)
so the RPC materializes only what is decoded.
Sourcepub async fn query_scalar<T>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>where
T: for<'de> FromGrpcValue<'de>,
pub async fn query_scalar<T>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>where
T: for<'de> FromGrpcValue<'de>,
Decode the single column of a single-row query (SELECT count(*),
SELECT max(x), …). Ok(None) when the query returned no row.
The column is identified by position: the row must carry exactly one
property (a defensive guard — the proto row is a map, so “first
column” is only well-defined for one-column rows), decoded via
FromGrpcValue. Aggregate queries
return a single row anyway (SELECT count(*)); anything wide
belongs in fetch_optional.
Sourcepub async fn write_returning_optional<T>(
&self,
database: &str,
command: &str,
parameters: impl Into<Params>,
) -> Result<Option<T>>
pub async fn write_returning_optional<T>( &self, database: &str, command: &str, parameters: impl Into<Params>, ) -> Result<Option<T>>
Run a write command that returns the stored row and decode it. The command must be a form whose response carries records:
INSERT INTO t SET …— returns the stored record as-is (the RPC runs withreturn_rows = true; noRETURNclause exists for INSERT — trailing… RETURN AFTERis a syntax error).UPDATE t SET … RETURN AFTER WHERE …—RETURN BEFORE|AFTERsits between the SET/UPSERT part and WHERE, not at statement end. TheUPSERTvariant additionally requires the WHERE column to carry an index.
Ok(None) when the statement matched nothing (RETURN AFTER on a
zero-row UPDATE); use upsert_returning
for the strict one-row contract.
Replaces the execute→extract→decode template at every returning-write call site.
Sourcepub async fn upsert_returning<T>(
&self,
database: &str,
command: &str,
parameters: impl Into<Params>,
) -> Result<T>
pub async fn upsert_returning<T>( &self, database: &str, command: &str, parameters: impl Into<Params>, ) -> Result<T>
write_returning_optional with a
one-row contract (empty result → ArcadeDbError::NotFound).
Sourcepub async fn lookup_by_key<T>(
&self,
database: &str,
type_name: &str,
key: &[(&str, GrpcValue)],
) -> Result<Option<T>>
pub async fn lookup_by_key<T>( &self, database: &str, type_name: &str, key: &[(&str, GrpcValue)], ) -> Result<Option<T>>
Typed lookup by a (single or composite) key on type_name: builds
SELECT FROM {type} WHERE k1 = :k0 AND k2 = :k1 LIMIT 1 with bound
parameters — no identity concept imported, just the Java API’s
lookupByKey semantics over plain equality.
Property/type names are validated identifiers (ASCII alphanumerics
and _); values are bound, never interpolated.
Sourcepub async fn count_type(&self, database: &str, type_name: &str) -> Result<i64>
pub async fn count_type(&self, database: &str, type_name: &str) -> Result<i64>
Count all records of a type (polymorphic — ArcadeDB SELECT FROM type includes subtypes), the Java API’s countType. One
query_scalar roundtrip.
Sourcepub async fn create_record(
&self,
database: &str,
class_name: &str,
props: Vec<(&str, GrpcValue)>,
) -> Result<CreateRecordResponse>
pub async fn create_record( &self, database: &str, class_name: &str, props: Vec<(&str, GrpcValue)>, ) -> Result<CreateRecordResponse>
Create a record of class_name from (property, value) pairs — the
typed single-record counterpart of INSERT-INTO SQL. Returns the
server-assigned rid.
Sourcepub async fn update_record_partial(
&self,
database: &str,
rid: &Link,
props: impl Into<Params>,
) -> Result<bool>
pub async fn update_record_partial( &self, database: &str, rid: &Link, props: impl Into<Params>, ) -> Result<bool>
Partially update a record by rid: only the given properties change,
everything else is left untouched (UpdateRecord’s partial payload).
The typed alternative to escaped-literal SET SQL; pair with
changed_param_map for diff-based
writes from DTOs.
Returns whether a record was actually updated (unknown rid → false).
Sourcepub async fn delete_record(&self, database: &str, rid: &Link) -> Result<bool>
pub async fn delete_record(&self, database: &str, rid: &Link) -> Result<bool>
Delete a record by rid. Returns whether a record was actually removed
(already-absent rid → false).
Sourcepub async fn bulk_insert(
&self,
database: &str,
target_class: &str,
key_columns: &[&str],
rows: Vec<GrpcRecord>,
) -> Result<InsertSummary>
pub async fn bulk_insert( &self, database: &str, target_class: &str, key_columns: &[&str], rows: Vec<GrpcRecord>, ) -> Result<InsertSummary>
Bulk-insert rows into target_class via the gRPC BulkInsert RPC — a
single round trip for many records. key_columns + ignore-conflict make
it idempotent (safe to re-run on a non-empty table). Used by the test
fixture generators to seed data efficiently.
Returns the server’s InsertSummary (inserted/updated/ignored counts).
Sourcepub async fn bulk_upsert(
&self,
database: &str,
target_class: &str,
key_columns: &[&str],
update_columns_on_conflict: &[&str],
rows: Vec<GrpcRecord>,
) -> Result<InsertSummary>
pub async fn bulk_upsert( &self, database: &str, target_class: &str, key_columns: &[&str], update_columns_on_conflict: &[&str], rows: Vec<GrpcRecord>, ) -> Result<InsertSummary>
Bulk upsert rows into target_class via the gRPC BulkInsert RPC with
CONFLICT_UPDATE (mode 1): key columns are matched against existing
records and the non-key columns are overwritten. One round trip for many
records — the batch analogue of UPDATE ... UPSERT, which the SQL path
only accepts when the WHERE columns carry an index.
key_columns must be covered by an index for conflict detection to be
reliable (a UNIQUE index on the match key is the sanctioned shape).
update_columns_on_conflict limits which columns are overwritten on a
match; empty = merge all non-key columns present on the incoming record.
Returns the server’s InsertSummary (inserted/updated/ignored counts).
Sourcepub async fn bulk_upsert_dtos<T>(
&self,
database: &str,
target_class: &str,
rows: Vec<T>,
) -> Result<InsertSummary>where
T: ToGrpcRecord + Send,
pub async fn bulk_upsert_dtos<T>(
&self,
database: &str,
target_class: &str,
rows: Vec<T>,
) -> Result<InsertSummary>where
T: ToGrpcRecord + Send,
The typed bulk_upsert: rows are
RecordEncode DTOs, the conflict key comes from the DTO’s
#[record(key)] fields (ToGrpcRecord::KEY_COLUMNS) — the call
site cannot disagree with the DTO about the identity — and every
present column is merged on conflict (absent Options keep their
stored values).
Errors up front when the DTO declares no key columns.
Sourcepub async fn stream_query<F>(
&self,
database: &str,
query: &str,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query<F>( &self, database: &str, query: &str, on_batch: F, ) -> Result<StreamSummary>
Execute a SQL query on the server-streaming RPC (StreamQuery),
feeding each result batch to on_batch as it arrives — ranking,
filtering, and discarding happen per batch while the server produces
the next one, instead of materializing the entire result set
client-side first.
The callback contract is consume_stream’s: borrowed views are
consumed inside the call, and ControlFlow::Break cancels the stream
early (the summary reports truncated). Prefer this over
query for large candidate sets; keep query for
small reads.
Sourcepub async fn stream_query_with_values<F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query_with_values<F>( &self, database: &str, query: &str, parameters: impl Into<Params>, on_batch: F, ) -> Result<StreamSummary>
stream_query with bound :name parameters —
same parameter-safety and plan-caching notes as
query_with_values.
Sourcepub async fn stream_query_with_options<F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
options: StreamOptions,
on_batch: F,
) -> Result<StreamSummary>
pub async fn stream_query_with_options<F>( &self, database: &str, query: &str, parameters: impl Into<Params>, options: StreamOptions, on_batch: F, ) -> Result<StreamSummary>
stream_query_with_values with
explicit execution knobs — the
StreamOptions knobs
(batch_size, retrieval_mode, projections) the plain methods
leave at server defaults.
Sourcepub async fn stream_query_rows<T, F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
pub async fn stream_query_rows<T, F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
Typed row streaming: each record is decoded into T (the
RecordDecode bound) and passed to on_row
as it arrives — the rows contract without
buffering the result set.
ControlFlow::Break stops the stream early (summary reports
truncated). A row that does not decode fails the whole call with
ArcadeDbError::Decode — fail-fast, matching the buffered path’s
whole-query error semantics.
Sourcepub async fn stream_query_rows_with_options<T, F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
options: StreamOptions,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
pub async fn stream_query_rows_with_options<T, F>(
&self,
database: &str,
query: &str,
parameters: impl Into<Params>,
options: StreamOptions,
on_row: F,
) -> Result<StreamSummary>where
T: for<'r> TryFrom<&'r GrpcRecord, Error = RecordDecodeError>,
F: FnMut(T) -> ControlFlow<()>,
stream_query_rows with explicit
StreamOptions.
Sourcepub async fn begin_transaction(
&self,
database: &str,
isolation: TransactionIsolation,
) -> Result<String>
pub async fn begin_transaction( &self, database: &str, isolation: TransactionIsolation, ) -> Result<String>
Begin an explicit server-side transaction.
Returns a transaction id; pass it to execute_in_transaction
and query_in_transaction, then finish with
commit_transaction or rollback_transaction.
NOTE: ArcadeDB keeps schema changes (DDL) outside transaction scope — they commit immediately in their own sub-transaction. Use the explicit transaction for record operations (the copy phase of an override rebuild) and verify the copy before committing; do not rely on it to make batch DDL atomic.
Sourcepub async fn execute_in_transaction(
&self,
database: &str,
language: &str,
command: &str,
transaction_id: &str,
) -> Result<ExecuteCommandResponse>
pub async fn execute_in_transaction( &self, database: &str, language: &str, command: &str, transaction_id: &str, ) -> Result<ExecuteCommandResponse>
Execute a command inside an explicitly-begun transaction.
The command runs with the transaction attached; it is only durable when
the transaction is later committed. (Schema statements still commit
immediately — see begin_transaction.)
Sourcepub async fn query_in_transaction(
&self,
database: &str,
query: &str,
transaction_id: &str,
) -> Result<QueryResult>
pub async fn query_in_transaction( &self, database: &str, query: &str, transaction_id: &str, ) -> Result<QueryResult>
Run a read query inside an explicitly-begun transaction, so the caller can verify what the transaction has written before committing.
Sourcepub async fn commit_transaction(
&self,
database: &str,
transaction_id: &str,
) -> Result<()>
pub async fn commit_transaction( &self, database: &str, transaction_id: &str, ) -> Result<()>
Commit an explicitly-begun transaction, making its record operations durable.
Sourcepub async fn rollback_transaction(
&self,
database: &str,
transaction_id: &str,
) -> Result<()>
pub async fn rollback_transaction( &self, database: &str, transaction_id: &str, ) -> Result<()>
Roll back an explicitly-begun transaction, discarding its record operations.
Sourcepub async fn transaction(
&self,
database: &str,
isolation: TransactionIsolation,
) -> Result<Transaction<'_>>
pub async fn transaction( &self, database: &str, isolation: TransactionIsolation, ) -> Result<Transaction<'_>>
Begin an explicit server-side transaction as a guard (Transaction).
The guard owns the transaction lifecycle: run commands with
Transaction::execute / Transaction::query, then finish with
Transaction::commit or Transaction::rollback. Dropping the
guard without finishing fires a best-effort background rollback (the
server’s idle-reaper is the backstop), so forgotten transactions
cannot leak.
Sourcepub async fn run_transaction<T, F, Fut>(
&self,
database: &str,
isolation: TransactionIsolation,
retries: u32,
body: F,
) -> Result<T>
pub async fn run_transaction<T, F, Fut>( &self, database: &str, isolation: TransactionIsolation, retries: u32, body: F, ) -> Result<T>
Run body inside an explicit transaction, retrying the whole block
up to retries extra times when the server reports an MVCC conflict
(concurrent modification) — the Java API’s
transaction(txBlock, retries). A fresh transaction is begun per
attempt; every failed attempt is rolled back before retrying.
Conflict detection is best-effort message matching (the gRPC surface
exposes no structured conflict code yet): concurrent, mvcc, or
needretry in the server message. Non-conflict errors and exhausted
retries return the last error, transaction rolled back.
DDL is outside transaction scope (see
begin_transaction) — record operations
only. Pairs with the Transaction drop-guard:
the guard makes multi-statement units atomic, this makes them
self-healing under concurrent writers.
Trait Implementations§
Source§impl Clone for DatabaseClient
impl Clone for DatabaseClient
Source§impl Deref for DatabaseClient
impl Deref for DatabaseClient
Auto Trait Implementations§
impl !Freeze for DatabaseClient
impl !RefUnwindSafe for DatabaseClient
impl !UnwindSafe for DatabaseClient
impl Send for DatabaseClient
impl Sync for DatabaseClient
impl Unpin for DatabaseClient
impl UnsafeUnpin for DatabaseClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request