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>>§expression_attribute_values: Option<HashMap<String, AttributeValue>>

Implementations§

source§

impl Expression

Methods related to PutItem operations.

source

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
source

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
source

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
source

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

Methods related to GetItem operations.

source

pub fn to_get_builder(self) -> GetBuilder

Uses this Expression to create a GetBuilder with the following set:

  • Projection expression
  • Expression attribute names
source

pub fn to_get_item_input_builder(self) -> GetItemInputBuilder

Uses this Expression to set the following on a GetItemInputBuilder:

  • Projection expression
  • Expression attribute names
source

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
source

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

Methods related to UpdateItem operations.

source

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
source

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
source

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
source

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

Methods related to DeleteItem operations.

source

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
source

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
source

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
source

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

Methods related to Query operations.

source

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
source

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
source

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

Methods related to Scan operations.

source

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
source

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
source

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

source

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?;
source

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
source§

impl Expression

Trait Implementations§

source§

impl Clone for Expression

source§

fn clone(&self) -> Expression

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Expression

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Expression

source§

fn eq(&self, other: &Expression) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Expression

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more