Struct dynamodb_expression::Expression
source · pub struct Expression {
pub condition_expression: Option<String>,
pub key_condition_expression: Option<String>,
pub update_expression: Option<String>,
pub filter_expression: Option<String>,
pub projection_expression: Option<String>,
pub expression_attribute_names: Option<HashMap<String, String>>,
pub expression_attribute_values: Option<HashMap<String, AttributeValue>>,
}
Expand description
The data needed for various aws_sdk_dynamodb
input types.
Use Builder
(via Expression::builder
) to create DynamoDB
condition, filter, projection, key condition, and update expressions.
You can use these methods to consume this and set up a DynamoDB operation. See their docs for examples.
See also the to_*_input_builder
and to_*_fluent_builder
methods for
populating aws_sdk_dynamodb
types.
You can use the fields on this struct to manually populate an
aws_sdk_dynamodb
input type, or you can use one of the many methods on
this to automatically build or populate one of those types.
Fields§
§condition_expression: Option<String>
The string to use as a DynamoDB condition expression.
Be sure to also use .expression_attribute_names
and
.expression_attribute_values
.
key_condition_expression: Option<String>
The string to use use as a DynamoDB key condition expression.
Be sure to also use .expression_attribute_names
and
.expression_attribute_values
.
update_expression: Option<String>
The string to use as a DynamoDB update expression.
Be sure to also use .expression_attribute_names
and
.expression_attribute_values
.
filter_expression: Option<String>
The string to use as a DynamoDB filter expression.
Be sure to also use .expression_attribute_names
and
.expression_attribute_values
.
projection_expression: Option<String>
The string to use as a DynamoDB projection expression.
Be sure to also use .expression_attribute_names
.
expression_attribute_names: Option<HashMap<String, String>>
DynamoDB expression attribute names.
expression_attribute_values: Option<HashMap<String, AttributeValue>>
DynamoDB expression attribute values.
Implementations§
source§impl Expression
impl Expression
Methods related to PutItem
operations.
sourcepub fn to_put_builder(self) -> PutBuilder
pub fn to_put_builder(self) -> PutBuilder
Uses this Expression
to create a PutBuilder
with the following set:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_put_item_input_builder(self) -> PutItemInputBuilder
pub fn to_put_item_input_builder(self) -> PutItemInputBuilder
Uses this Expression
to set the following on a PutItemInputBuilder
:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_put_item_fluent_builder(
self,
builder: PutItemFluentBuilder
) -> PutItemFluentBuilder
pub fn to_put_item_fluent_builder( self, builder: PutItemFluentBuilder ) -> PutItemFluentBuilder
Uses this Expression
to set the following on a PutItemFluentBuilder
before returning it:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn put_item(self, client: &Client) -> PutItemFluentBuilder
pub fn put_item(self, client: &Client) -> PutItemFluentBuilder
Sets up a put_item
using the provided Client
and uses this Expression
to set the following on the PutItemFluentBuilder
before returning it:
- Condition expression
- Expression attribute names
- Expression attribute values
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::{types::AttributeValue, Client};
use dynamodb_expression::{Expression, Path};
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let output = Expression::builder()
.with_condition("name".parse::<Path>()?.attribute_not_exists())
.build()
.put_item(&client)
.table_name("people")
.item("name", AttributeValue::S(String::from("Jill")))
.item("age", AttributeValue::N(40.to_string()))
.send()
.await?;
source§impl Expression
impl Expression
Methods related to GetItem
operations.
sourcepub fn to_get_builder(self) -> GetBuilder
pub fn to_get_builder(self) -> GetBuilder
Uses this Expression
to create a GetBuilder
with the following set:
- Projection expression
- Expression attribute names
sourcepub fn to_get_item_input_builder(self) -> GetItemInputBuilder
pub fn to_get_item_input_builder(self) -> GetItemInputBuilder
Uses this Expression
to set the following on a GetItemInputBuilder
:
- Projection expression
- Expression attribute names
sourcepub fn to_get_item_fluent_builder(
self,
builder: GetItemFluentBuilder
) -> GetItemFluentBuilder
pub fn to_get_item_fluent_builder( self, builder: GetItemFluentBuilder ) -> GetItemFluentBuilder
Uses this Expression
to set the following on a GetItemFluentBuilder
before returning it:
- Projection expression
- Expression attribute names
sourcepub fn get_item(self, client: &Client) -> GetItemFluentBuilder
pub fn get_item(self, client: &Client) -> GetItemFluentBuilder
Sets up a get_item
using the provided Client
and uses this Expression
to set the following on the GetItemFluentBuilder
before returning it:
- Projection expression
- Expression attribute names
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::{types::AttributeValue, Client};
use dynamodb_expression::Expression;
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let output = Expression::builder()
.with_projection(["name", "age"])
.build()
.get_item(&client)
.table_name("people")
.key("id", AttributeValue::N(42.to_string()))
.send()
.await?;
source§impl Expression
impl Expression
Methods related to UpdateItem
operations.
sourcepub fn to_update_builder(self) -> UpdateBuilder
pub fn to_update_builder(self) -> UpdateBuilder
Uses this Expression
to create an UpdateBuilder
with the following set:
- Update expression
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_update_item_input_builder(self) -> UpdateItemInputBuilder
pub fn to_update_item_input_builder(self) -> UpdateItemInputBuilder
Uses this Expression
to create an UpdateItemInputBuilder
with the following set:
- Update expression
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_update_item_fluent_builder(
self,
builder: UpdateItemFluentBuilder
) -> UpdateItemFluentBuilder
pub fn to_update_item_fluent_builder( self, builder: UpdateItemFluentBuilder ) -> UpdateItemFluentBuilder
Uses this Expression
to set the following on an UpdateItemFluentBuilder
before returning it:
- Update expression
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn update_item(self, client: &Client) -> UpdateItemFluentBuilder
pub fn update_item(self, client: &Client) -> UpdateItemFluentBuilder
Sets up an update_item
using the provided Client
and uses this Expression
to set the following on the UpdateItemFluentBuilder
before returning it:
- Update expression
- Condition expression
- Expression attribute names
- Expression attribute values
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::{types::AttributeValue, Client};
use dynamodb_expression::{Expression, Num, Path};
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let age: Path = "age".parse()?;
let output = Expression::builder()
.with_condition(age.clone().equal(Num::new(40)))
.with_update(age.math().add(1))
.build()
.update_item(&client)
.table_name("people")
.key("name", AttributeValue::S(String::from("Jack")))
.send()
.await?;
source§impl Expression
impl Expression
Methods related to DeleteItem
operations.
sourcepub fn to_delete_builder(self) -> DeleteBuilder
pub fn to_delete_builder(self) -> DeleteBuilder
Uses this Expression
to create a DeleteBuilder
with the following set:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_delete_item_input_builder(self) -> DeleteItemInputBuilder
pub fn to_delete_item_input_builder(self) -> DeleteItemInputBuilder
Uses this Expression
to set the following on a DeleteItemInputBuilder
:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_delete_item_fluent_builder(
self,
builder: DeleteItemFluentBuilder
) -> DeleteItemFluentBuilder
pub fn to_delete_item_fluent_builder( self, builder: DeleteItemFluentBuilder ) -> DeleteItemFluentBuilder
Uses this Expression
to set the following on a DeleteItemFluentBuilder
before returning it:
- Condition expression
- Expression attribute names
- Expression attribute values
sourcepub fn delete_item(self, client: &Client) -> DeleteItemFluentBuilder
pub fn delete_item(self, client: &Client) -> DeleteItemFluentBuilder
Sets up a delete_item
using the provided Client
and uses this Expression
to set the following on the DeleteItemFluentBuilder
before returning it:
- Condition expression
- Expression attribute names
- Expression attribute values
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::{types::AttributeValue, Client};
use dynamodb_expression::{Expression, Num, Path};
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let output = Expression::builder()
.with_condition("age".parse::<Path>()?.less_than(Num::new(20)))
.build()
.delete_item(&client)
.table_name("people")
.key("name", AttributeValue::S(String::from("Jack")))
.send()
.await?;
source§impl Expression
impl Expression
Methods related to Query
operations.
sourcepub fn to_query_input_builder(self) -> QueryInputBuilder
pub fn to_query_input_builder(self) -> QueryInputBuilder
Uses this Expression
to create a QueryInputBuilder
with the following set:
- Key condition expression
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_query_fluent_builder(
self,
builder: QueryFluentBuilder
) -> QueryFluentBuilder
pub fn to_query_fluent_builder( self, builder: QueryFluentBuilder ) -> QueryFluentBuilder
Uses this Expression
to set the following on a QueryFluentBuilder
before returning it:
- Key condition expression
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
sourcepub fn query(self, client: &Client) -> QueryFluentBuilder
pub fn query(self, client: &Client) -> QueryFluentBuilder
Sets up a query
using the provided Client
and uses this Expression
to set the following on the QueryFluentBuilder
before returning it:
- Key condition expression
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::Client;
use dynamodb_expression::{Expression, Num, Path};
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let output = Expression::builder()
.with_filter(
"name"
.parse::<Path>()?
.attribute_exists()
.and("age".parse::<Path>()?.greater_than_or_equal(Num::new(25))),
)
.with_projection(["name", "age"])
.with_key_condition("id".parse::<Path>()?.key().equal(Num::new(42)))
.build()
.query(&client)
.table_name("people")
.send()
.await?;
source§impl Expression
impl Expression
Methods related to Scan
operations.
sourcepub fn to_scan_input_builder(self) -> ScanInputBuilder
pub fn to_scan_input_builder(self) -> ScanInputBuilder
Uses this Expression
to create a ScanInputBuilder
with the following set:
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
sourcepub fn to_scan_fluent_builder(
self,
builder: ScanFluentBuilder
) -> ScanFluentBuilder
pub fn to_scan_fluent_builder( self, builder: ScanFluentBuilder ) -> ScanFluentBuilder
Uses this Expression
to set the following on a ScanFluentBuilder
before returning it:
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
sourcepub fn scan(self, client: &Client) -> ScanFluentBuilder
pub fn scan(self, client: &Client) -> ScanFluentBuilder
Sets up a scan
using the provided Client
and uses this Expression
to set the following on the ScanFluentBuilder
before returning it:
- Filter expression
- Projection expression
- Expression attribute names
- Expression attribute values
§Example
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::Client;
use dynamodb_expression::{Expression, Num, Path};
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let output = Expression::builder()
.with_filter("age".parse::<Path>()?.greater_than_or_equal(Num::new(25)))
.with_projection(["name", "age"])
.build()
.scan(&client)
.table_name("people")
.send()
.await?;
source§impl Expression
impl Expression
sourcepub fn to_keys_and_attributes_builder(self) -> KeysAndAttributesBuilder
pub fn to_keys_and_attributes_builder(self) -> KeysAndAttributesBuilder
Uses this Expression
to create a KeysAndAttributesBuilder
with the following set:
- Projection expression
- Expression attribute names
§Example
use std::collections::HashMap;
use aws_config::BehaviorVersion;
use aws_sdk_dynamodb::{types::AttributeValue, Client};
use dynamodb_expression::Expression;
let client = Client::new(&aws_config::load_defaults(BehaviorVersion::latest()).await);
let expression = Expression::builder()
.with_projection(["name", "age"])
.build();
let key = HashMap::from([("id".to_string(), AttributeValue::N(42.to_string()))]);
let output = client
.batch_get_item()
.request_items(
"leads",
expression
.clone()
.to_keys_and_attributes_builder()
.keys(key.clone())
.build()
.unwrap(),
)
.request_items(
"customers",
expression
.to_keys_and_attributes_builder()
.keys(key)
.build()
.unwrap(),
)
.send()
.await?;
sourcepub fn to_condition_check_builder(self) -> ConditionCheckBuilder
pub fn to_condition_check_builder(self) -> ConditionCheckBuilder
Uses this Expression
to create a ConditionCheckBuilder
with the following set:
- Condition expression
- Expression attribute names
- Expression attribute values
Trait Implementations§
source§impl Clone for Expression
impl Clone for Expression
source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Expression
impl Debug for Expression
source§impl PartialEq for Expression
impl PartialEq for Expression
source§fn eq(&self, other: &Expression) -> bool
fn eq(&self, other: &Expression) -> bool
self
and other
values to be equal, and is used
by ==
.