Skip to main content

dynamodb_stream_query

Function dynamodb_stream_query 

Source
pub fn dynamodb_stream_query<TD: TableDefinition>(
    builder: QueryFluentBuilder,
) -> impl Stream<Item = Result<Vec<Item<TD>>>>
Expand description

Creates a lazy async Stream of query results with automatic pagination.

Each element yielded by the stream is a Vec<Item<TD>> representing one page of results. Pages are fetched on demand as the stream is consumed. Each page’s LastEvaluatedKey is used as the ExclusiveStartKey for the next request. This is the low-level function used by QueryRequest::stream. Prefer using DynamoDBItemOp::query or QueryRequest directly unless you are working with a raw QueryFluentBuilder.

§Examples

use dynamodb_facade::dynamodb_stream_query;
use futures_util::StreamExt;
use std::pin::pin;

let builder = client
    .query()
    .table_name("platform")
    .key_condition_expression("PK = :pk")
    .expression_attribute_values(
        ":pk",
        aws_sdk_dynamodb::types::AttributeValue::S("USER#user-1".into()),
    );
let stream = dynamodb_stream_query::<PlatformTable>(builder);
// Must pin the stream
let mut stream = pin!(stream);

while let Some(result) = stream.next().await {
    let page /* : Vec<Item<PlatformTable>> */ = result?;
    for item in page {
        let _ = item;
    }
}