Skip to content

Commit 1baaa58

Browse files
committed
Added partition & sort keys
1 parent c4fd8b7 commit 1baaa58

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

plugin/ddbds.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"fmt"
5+
"strings"
56

67
ddbds "github.com/Vanssh-k/go-ds-dynamodb"
78
"github.com/aws/aws-sdk-go/aws"
@@ -71,6 +72,15 @@ func (c *DDBConfig) DiskSpec() fsrepo.DiskSpec {
7172
}
7273
}
7374

75+
// Extracts the Sort Key from DSKey
76+
func extractSortKey(dsKey string) (string, error) {
77+
parts := strings.SplitN(dsKey, "/", 3)
78+
if len(parts) < 3 {
79+
return "", fmt.Errorf("invalid DSKey format: %s", dsKey)
80+
}
81+
return parts[2], nil
82+
}
83+
7484
func (c *DDBConfig) Create(path string) (repo.Datastore, error) {
7585
awsConfig := &aws.Config{
7686
Region: aws.String(c.Region),
@@ -87,5 +97,12 @@ func (c *DDBConfig) Create(path string) (repo.Datastore, error) {
8797

8898
ddbClient := dynamodb.New(sess)
8999

90-
return ddbds.New(ddbClient, c.Table), nil
100+
ddbDS := ddbds.New(
101+
ddbClient,
102+
c.Table,
103+
ddbds.WithPartitionKey("PartitionKey"),
104+
ddbds.WithSortKey("SortKey"),
105+
)
106+
107+
return ddbDS, nil
91108
}

0 commit comments

Comments
 (0)