batchGetItem

Spec

async batchGetItem(
    tnmInput: TynamoBatchGetItemInput<TSource>
): Promise<TynamoBatchGetItemOutput<TSource>>

Unlike Dynamo, there is no limit.

Internally, they are split properly and processed in parallel.

Input

export interface TynamoBatchGetItemInput<TSource> {
    RequestItems: Partial<TSource>[];
    
    // Derived from DynamoDB.
    ReturnConsumedCapacity?: ReturnConsumedCapacity;
    ConsistentRead?: ConsistentRead;
    ProjectionExpression?: ProjectionExpression;
    ExpressionAttributeNames?: ExpressionAttributeNameMap;
}

Unlisted param is derived from DynamoDB.

Check here for more information.

Output

export interface TynamoBatchGetItemOutput<TSource> {
    Responses?: TSource[];
    UnprocessedKeys?: Partial<TSource>[];

    // Derived from DynamoDB.
    $response?: Response<BatchGetItemOutput, AWSError>;
    ConsumedCapacity?: ConsumedCapacityMultiple;
}

Unlisted param is derived from DynamoDB.

Check here for more information.

Example

@DynamoEntity()
class Cat {
    @DynamoProperty({ keyType: KeyType.hash })
    id!: number;

    @DynamoProperty({ keyType: KeyType.attr })
    name!: string;

    constructor(id: number, name: string) {
        this.id = id;
        this.name = name;
    }
}

const tynamo: Tynamo = new Tynamo({
    region: "ap-northeast-2",
    endpoint: "http://localhost:8000"
});
const tynamoTable = tynamo.getTableOf(Cat);

const cats: Cat[] = [];
for(let i=0; i<100; i++){
    cats.push(new Cat(i, ""));
}

await tynamoTable.batchGetItem({
    RequestItems: cats
});

Last updated