This repository contains a sample code demonstrating how to implement pagination, ordering, and free-text search on the sort key in DynamoDB using Go and the Echo web framework.
-
Set Up a DynamoDB Table: Create a DynamoDB table with the desired structure.
-
Update Configuration: Open main.go and update the tableName variable with the name of your DynamoDB table.
var tableName = "YourTableName"
-
Update Attribute Mapping: Ensure that the attributes in the
Entrystruct match the attributes in your DynamoDB table.type Entry struct { KeyCond string `dynamodbav:"key_condition" json:"key_condition"` SortKey string `dynamodbav:"sort_key" json:"sort_key"` }
-
Run the Application:
go run main.go
The server will be accessible at
http://localhost:8080. -
Make HTTP Requests:
Make requests to the
/paginateendpoint with query parameters to test pagination, ordering, and free-text search.curl "http://localhost:8080/paginate?key_condition=test&page=1&pagesize=10&orderby=sort_key&search=example"