pub struct TableRequest { /* private fields */ }
Expand description
Struct used for creating or modifying a table in the NoSQL Database.
This is the main method for creating, altering, and dropping tables in the NoSQL Database. It can also be used to alter table limits for Cloud operation.
Example:
use oracle_nosql_rust_sdk::TableRequest;
use oracle_nosql_rust_sdk::types::*;
// Create an example table
TableRequest::new("testusers")
.statement(
"create table if not exists testusers (id integer, name string,
created timestamp(3), primary key(id))",
)
// the following line is only needed for Cloud mode
.limits(&TableLimits::provisioned(1000, 1000, 10))
.execute(&handle)
.await?
// wait up to 15 seconds for table to be created
.wait_for_completion_ms(&handle, 15000, 500)
.await?;
Implementations§
Source§impl TableRequest
impl TableRequest
Sourcepub fn new(table_name: &str) -> TableRequest
pub fn new(table_name: &str) -> TableRequest
Create a new TableRequest.
table_name
is required and must be non-empty.
Sourcepub fn timeout(self, t: &Duration) -> Self
pub fn timeout(self, t: &Duration) -> Self
Specify the timeout value for the request.
This is optional.
If set, it must be greater than or equal to 1 millisecond, otherwise an
IllegalArgument error will be returned.
If not set, the default timeout value configured for the Handle
is used.
Note this is just the timeout for the initial request. The actual operation may take significantly longer,
and its completion should be waited for by calling TableResult::wait_for_completion()
.
Sourcepub fn compartment_id(self, compartment_id: &str) -> Self
pub fn compartment_id(self, compartment_id: &str) -> Self
Cloud Service only: set the name or id of a compartment to be used for this operation.
The compartment may be specified as either a name (or path for nested compartments) or as an id (OCID).
A name (vs id) can only be used when authenticated using a specific user identity. It is not available if
the associated handle authenticated as an Instance Principal (which can be done when calling the service from
a compute instance in the Oracle Cloud Infrastructure: see HandleBuilder::cloud_auth_from_instance()
.)
If no compartment is given, the root compartment of the tenancy will be used.
Sourcepub fn namespace(self, namespace: &str) -> TableRequest
pub fn namespace(self, namespace: &str) -> TableRequest
On-premises only: set the namespace for the operation.
Sourcepub fn statement(self, stmt: &str) -> TableRequest
pub fn statement(self, stmt: &str) -> TableRequest
Set the DDL statement for the table operation.
This is required, unless the operation is used solely to change the table
limits with TableRequest::limits()
.
Sourcepub fn limits(self, limits: &TableLimits) -> TableRequest
pub fn limits(self, limits: &TableLimits) -> TableRequest
Cloud only: specify table limits for the table.
This method can be used when creating a table, or later to change the limits on an existing table.
Sourcepub fn match_etag(self, match_etag: &str) -> TableRequest
pub fn match_etag(self, match_etag: &str) -> TableRequest
Cloud only: set a matching tag for the operation to succeed.
This method sets an ETag in the request that must be matched for the operation
to proceed. The ETag must be non-empty and have been returned in a
previous TableResult
. This is a form of optimistic concurrency
control, allowing an application to ensure that no unexpected modifications
have been made to the table.
Sourcepub async fn execute(&self, h: &Handle) -> Result<TableResult, NoSQLError>
pub async fn execute(&self, h: &Handle) -> Result<TableResult, NoSQLError>
Execute the table request.
This starts the asynchronous execution of the request in the system. The returned result should be
used to wait for completion by calling TableResult::wait_for_completion()
.