# README
dygo - DynamoDB Client for Go
Dygo is a user-friendly, feature-rich GoLang client for interfacing with AWS DynamoDB. It offers a fluent interface with method chaining, optional authorization and data validation, simplifying the process of interacting with DynamoDB.
Features
- Easy-to-Use Interface: Simple, intuitive methods for common DynamoDB operations.
- Method Chaining: Fluent interface allowing for cleaner, more readable code.
- Authorization Support: Optional authorization features to secure your database operations.
- Data Validation: Built-in validation to ensure data integrity.
- Performance Optimized: Minimized overhead for high efficiency in production environments.
Installation
Install Dygo with go get
:
go get github.com/QuollioLabs/dygo
Quick Start
Here's a quick example to get you started:
package main
import (
"github.com/QuollioLabs/dygo"
"context"
)
func main() {
// Initialize client
db, err := dygo.NewClient(
dygo.WithTableName("test-table"),
dygo.WithRegion("ap-northeast-1"),
dygo.WithPartitionKey("pk"),
dygo.WithSortKey("sk"),
)
if err != nil {
// handle error
}
// Example: Insert item
err := db.
Item(newData).
Create(context.Background())
if err != nil {
// handle error
}
// Example: Fetching an item
data := dataItem{}
err = db.
PK(PK).
SK(dygo.Equal(SK)).
GetItem(context.Background(), &data)
if err != nil {
// handle error
}
}
Documentation
Full go doc
style documentation for the package can be viewed online without
installing this package by using the GoDoc site here:
http://pkg.go.dev/github.com/QuollioLabs/dygo
# Functions
BeginsWith returns a SortKeyFunc that can be used to create a KeyConditionBuilder for filtering items based on a prefix match with the given prefix value.
Between is a function that returns a SortKeyFunc which represents a key condition builder for the BETWEEN condition in DynamoDB.
ConditionAttributeExists returns a ConditionFunc that checks if the specified attribute exists in the item.
ConditionAttributeNotExists returns a ConditionFunc that checks if the specified attribute does not exist in the item.
ConditionBeginsWith returns a ConditionFunc that checks item based on whether the attribute's value begins with the specified prefix.
ConditionBetween returns a ConditionFunc that checks if the attribute value is between two specified values.
ConditionEqual returns a ConditionFunc that checks if the attribute value is equal to the specified value.
ConditionGreaterThan returns a ConditionFunc that checks if the attribute value is greater than the specified value.
ConditionGreaterThanOrEqual returns a ConditionFunc that checks if the attribute value is greater than or equal to the specified value.
ConditionIn returns a ConditionFunc that checks if the attribute value is one of the specified values.
ConditionLessThan returns a ConditionFunc that checks if the attribute value is less than the specified value.
ConditionLessThanOrEqual returns a ConditionFunc that checks if the attribute value is less than or equal to the specified value.
ConditionNotEqual returns a ConditionFunc that checks if the attribute value is not equal to the specified value.
Equal returns a SortKeyFunc that generates a KeyConditionBuilder for the "Equal" condition.
GreaterThan returns a SortKeyFunc that generates a KeyConditionBuilder for a greater than condition.
GreaterThanOrEqual returns a SortKeyFunc that generates a KeyConditionBuilder for a greater than or equal condition.
KeyBeginsWith returns a FilterFunc that filters items based on whether the key begins with the specified prefix.
KeyBetween returns a FilterFunc that generates a condition builder for a keyName that checks if its value is between the start and end values.
KeyContains returns a FilterFunc that checks if the given value is contained in the key's value.
KeyEqual returns a FilterFunc that filters based on the equality of a key's value.
KeyGreaterThan returns a FilterFunc that filters items based on the specified key being greater than the given value.
KeyGreaterThanOrEqual returns a FilterFunc that filters items where the value of the specified key is greater than or equal to the given value.
KeyIn returns a FilterFunc that checks if the given value is present in the specified keyName.
KeyLessThan returns a FilterFunc that filters items based on whether the value of the specified key is less than the given value.
KeyLessThanOrEqual returns a FilterFunc that filters items where the value of the specified key is less than or equal to the given value.
KeyNotContains returns a FilterFunc that filters out items where the value of the specified key does not contain the given value.
KeyNotEqual returns a FilterFunc that generates a condition builder for a key that is not equal to the specified value.
KeyNotNull returns a FilterFunc that checks if the specified key is not null.
KeyNull returns a FilterFunc that checks if the specified key does not exist in the DynamoDB item.
LessThan returns a SortKeyFunc that generates a KeyConditionBuilder for a less than condition.
LessThanOrEqual returns a SortKeyFunc that generates a KeyConditionBuilder for a less than or equal to comparison.
NewClient creates a new instance of the Client struct with the provided options.
WithEndpoint is an optional option function that sets the endpoint for the client.
WithGSI is an optional option function that adds a Global Secondary Index (GSI) to the client.
WithKeySeparator sets the key separator for the client.
WithLogger is an optional option function that sets the logger for the client.
WithPartitionKey is a mandatory option function that sets the partition key for the client.
WithProfile is a mandatory option function that sets the profile for the client.
WithRegion is a mandatory option function that sets the region for the client.
WithRetry is an optional option function that sets the maximum number of retries for a client.
WithSortKey is an optional option function that sets the sort key for the client.
WithTableName is a mandatory option function that sets the table name for the client.
# Type aliases
ConditionFunc returns a condition builder for an attribute.
FilterFunc returns a condition builder for a key.
No description provided by the author
SortKeyFunc returns a KeyConditionBuilder and a value of any type.