async getItem<TSource>(
tnmInput: TynamoGetItemInput<TSource>
): Promise<TynamoGetItemOutput<TSource>>;
export interface TynamoGetItemInput<TSource> {
Key: TSource;
// Derived from DynamoDB.
ConsistentRead?: ConsistentRead;
ReturnConsumedCapacity?: ReturnConsumedCapacity;
ProjectionExpression?: ProjectionExpression;
ExpressionAttributeNames?: ExpressionAttributeNameMap;
}
Unlisted param is derived from DynamoDB
.
Check here for more information.
export interface TynamoGetItemOutput<TSource> {
Item?: TSource;
// Derived from DynamoDB.
ConsumedCapacity?: ConsumedCapacity;
}
Unlisted param is derived from GetItemOutput
.
Check here for more information.
@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);
await tynamoTable.getItem({
Key: new Cat(666, ""),
ProjectionExpression: "#name"
});