async query(
tnmInput: TynamoQueryInput<TSource>
): Promise<TynamoQueryOutput<TSource>>
export interface TynamoQueryInput<TSource> {
ExclusiveStartKey?: TSource;
ExpressionAttributeValues?: any;
// Derived from DynamoDB.
IndexName?: IndexName;
Select?: Select;
Limit?: PositiveIntegerObject;
ConsistentRead?: ConsistentRead;
ScanIndexForward?: BooleanObject;
ReturnConsumedCapacity?: ReturnConsumedCapacity;
ProjectionExpression?: ProjectionExpression;
FilterExpression?: ConditionExpression;
KeyConditionExpression?: KeyExpression;
ExpressionAttributeNames?: ExpressionAttributeNameMap;
}
export interface TynamoQueryOutput<TSource> {
Items?: TSource[];
LastEvaluatedKey?: TSource;
// Derived from DynamoDB.
$response: AWS.Response<QueryOutput, AWS.AWSError>;
Count?: Integer;
ScannedCount?: Integer;
ConsumedCapacity?: ConsumedCapacity;
}
@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;
}
}
@DynamoEntity()
class Args {
@DynamoProperty({ keyType: KeyType.hash })
prefix!: string;
constructor(prefix: string){
this.prefix= prefix;
}
}
const tynamo: Tynamo = new Tynamo({
region: "ap-northeast-2",
endpoint: "http://localhost:8000"
});
const tynamoTable = tynamo.getTableOf(Cat);
await tynamoTable.query({
FilterExpression: "begins_with(#name, :prefix)",
ExpressionAttributeValues: new Args("gar"),
ProjectionExpression: "#id, #name"
});