batchGetItem
Spec
async batchGetItem(
tnmInput: TynamoBatchGetItemInput<TSource>
): Promise<TynamoBatchGetItemOutput<TSource>>
Input
export interface TynamoBatchGetItemInput<TSource> {
RequestItems: Partial<TSource>[];
// Derived from DynamoDB.
ReturnConsumedCapacity?: ReturnConsumedCapacity;
ConsistentRead?: ConsistentRead;
ProjectionExpression?: ProjectionExpression;
ExpressionAttributeNames?: ExpressionAttributeNameMap;
}
Name
Type
Info
RequestItems
Partial<@DynamoEntity>[]
Primary key of item to read.
Output
export interface TynamoBatchGetItemOutput<TSource> {
Responses?: TSource[];
UnprocessedKeys?: Partial<TSource>[];
// Derived from DynamoDB.
$response?: Response<BatchGetItemOutput, AWSError>;
ConsumedCapacity?: ConsumedCapacityMultiple;
}
Name
Type
Info
Responses
@DynamoEntity[]
Result of batchGet
operation.
UnprocessedKeys
Partial<@DynamoEntity>[]
Primary key of failed item.
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
Was this helpful?