Struct edgedb_client::Client[][src]

pub struct Client { /* fields omitted */ }
Expand description

A database connection pool

This is main way how to interact with the database. Usually it’s created using connect function.

Implementations

Create a new connection pool

Note this does not create any connection immediately. Use ensure_connection() to establish a connection and verify that connection credentials are okay.

Start shutting down connection pool

Note: this waits for all connections to be released when called on the first call. But if multiple calls are executed concurrently only the first one will wait (subsequent ones will exit immediately).

Ensure that there is at least one working connection to the pool

This is often used at the start of the application to error out on invalid connection configuration earlier.

Execute a query returning a collection of results

Most of the times you have to specify return type for the query:

let greeting = pool.query::<String, _>("SELECT 'hello'", &());
// or
let greeting: Vec<String> = pool.query("SELECT 'hello'", &());

This method can be used both with static arguments, like a tuple of scalars. And with dynamic arguments edgedb_protocol::value::Value. Similarly dynamically typed results are also suported.

Execute a query returning a single result

Most of the times you have to specify return type for the query:

let greeting = pool.query::<String, _>("SELECT 'hello'", &());
// or
let greeting: String = pool.query("SELECT 'hello'", &());

The query must return exactly one element. If the query returns more than one element, an ResultCardinalityMismatchError is raised, if it returns an empty set, an NoDataError is raised.

This method can be used both with static arguments, like a tuple of scalars. And with dynamic arguments edgedb_protocol::value::Value. Similarly dynamically typed results are also suported.

Execute a query returning result as a JSON

Run a singleton-returning query and return its element in JSON

The query must return exactly one element. If the query returns more than one element, an ResultCardinalityMismatchError is raised, if it returns an empty set, an NoDataError is raised.

Execute an EdgeQL command (or commands).

Note: If the results of query are desired, query() or query_single() should be used instead.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.