I am new to AWS Lambda, Amazon DynamoDB and serverless. I have one user table want to do like this.
- I want to fetch records pagination wise in each page fetch 10 records from the user table,
- I want to make sorting on columns like name and email. This both column with string datatype.
I am using serverless with node.js. Here I'm attaching my serverless.yaml file
UserDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: 'user'
For sorting i'm trying with this query
let params = {
TableName: 'user',
limit: 10,
ScanIndexForward: false
};
dynamoDb.scan(params, (error, result) => { })
But I didn't get a response as per my requirement. Please help me here I'm new into this. Thanks in advance.