简体   繁体   中英

How to get total count of data from dynamodb in aws appsync for pagination?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM