Reputation: 47
I am working on web app using aws amplify. And I am using Appsync GraphQL as web server. But I don't know a way to get a total count of data from Dynamodb through aws appsync. Please help me.
Upvotes: 0
Views: 2359
Reputation: 6158
How weird this can feel when coming from a SQL background, there is no easy way to do this in DynamoDB. The suggested approach is to perform multiple Scan operations until reaching the end and record the scannedCount
value as you go.
You won't be able to achieve this in AWS AppSync natively, if you absolutely need to do this through AppSync you can use a Lambda resolver that will perform the Scan
operations.
You could also keep track of all the PutItem
and DeleteItem
operation on your table using DynamoDB streams and increment/decrement a counter somewhere. Again this might be fragile if your Lambda ever loses track.
Upvotes: 3