dygo

package module
v0.1.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

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

Documentation

Overview

dygo is a Go package that provides a simple and clean interface for interacting with DynamoDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the main struct for the dygo package. It contains DynamoDB client, table name, partition key, sort key, and other configuration options.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new instance of the Client struct with the provided options. It initializes the DynamoDB client using provided configuration. Returns the created Client instance or an error if any.

Example:

dbEndpoint := "http://localhost:8000"
dbClient, err := NewClient(
	WithTableName("test-table-1"),
	WithRegion("ap-northeast-1"),
	WithPartitionKey("_partition_key"),
	WithSortKey("_sort_key"),
	WithGSI("gsi-name", "_entity_type", "_sort_key"),
	WithEndpoint(dbEndpoint),
)

func (*Client) GSI

func (c *Client) GSI(indexName string, partitionKeyValue any, f SortKeyFunc) *Item

GSI sets Global Secondary Index (GSI) for quiry. It takes the indexName string, partitionKeyValue any, and f SortKeyFunc as parameters. The indexName specifies the name of the GSI. The partitionKeyValue specifies the value of the partition key for the GSI query. The f SortKeyFunc is a function that defines the sort key for the GSI query. It can be Equal, BeginsWith, Between, LessThan, LessThanEqual, GreaterThan, GreaterThanEqual or nil It returns an Item object that can be used to perform operations on the GSI.

Example:

 err = db.
	GSI("gsi-name", "room", dygo.Equal("current")).
	Query(context.Background()).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Client) Item

func (c *Client) Item(item ItemData) *Item

Item returns a new instance of the Item struct, initialized with the provided item and client. item must implement method : Validate() error

Example:

If passing employee struct, it should implement Validate() error

func (e employee) Validate() error {
	return nil
}
emp := employee{}
err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	GetItem(context.Background(), &emp)

func (*Client) ItemRaw added in v0.1.9

func (c *Client) ItemRaw(items map[string]types.AttributeValue) *Item

ItemRaw returns a new instance of the Item struct, initialized with the provided raw item and client. It does not require the item to implement the Validate() method.

Example:

newItem := new(Item)
for _, item := range items {
	db.ItemRaw(item).AddBatchUpsertRawItem(newItem)
}
// here items is of type []map[string]types.AttributeValue

err = newItem.BatchUpsertItem(context.Background(), 10)
if err != nil {
	log.Fatal(err)
}

func (*Client) PK

func (c *Client) PK(value any) *Item

PK sets the specified value as the partition key value in current query.

func (*Client) Table

func (c *Client) Table(value string) *Client

Table sets the name of the table for the current query. It returns the modified Client instance.

func (*Client) UpdateItemRaw added in v0.1.12

func (c *Client) UpdateItemRaw(item map[string]types.AttributeValue) *Item

UpdateItem returns a new instance of the Item struct, initialized with the provided item and client. It is used to update an existing item in the table.

Example:

newItem := new(Item)
for _, item := range items {
	db.UpdateItemRaw(item).AddUpdateRawItem(newItem)
}

err = newItem.Update(context.Background(), 5)

type ConditionFunc added in v0.1.17

type ConditionFunc func(string) expression.ConditionBuilder

ConditionFunc returns a condition builder for an attribute.

func ConditionAttributeExists added in v0.1.17

func ConditionAttributeExists() ConditionFunc

ConditionAttributeExists returns a ConditionFunc that checks if the specified attribute exists in the item.

func ConditionAttributeNotExists added in v0.1.17

func ConditionAttributeNotExists() ConditionFunc

ConditionAttributeNotExists returns a ConditionFunc that checks if the specified attribute does not exist in the item.

func ConditionBeginsWith added in v0.1.17

func ConditionBeginsWith(prefix any) ConditionFunc

ConditionBeginsWith returns a ConditionFunc that checks item based on whether the attribute's value begins with the specified prefix.

func ConditionBetween added in v0.1.17

func ConditionBetween(start, end any) ConditionFunc

ConditionBetween returns a ConditionFunc that checks if the attribute value is between two specified values.

func ConditionEqual added in v0.1.17

func ConditionEqual(value any) ConditionFunc

ConditionEqual returns a ConditionFunc that checks if the attribute value is equal to the specified value.

func ConditionGreaterThan added in v0.1.17

func ConditionGreaterThan(value any) ConditionFunc

ConditionGreaterThan returns a ConditionFunc that checks if the attribute value is greater than the specified value.

func ConditionGreaterThanOrEqual added in v0.1.17

func ConditionGreaterThanOrEqual(value any) ConditionFunc

ConditionGreaterThanOrEqual returns a ConditionFunc that checks if the attribute value is greater than or equal to the specified value.

func ConditionIn added in v0.1.17

func ConditionIn(value any) ConditionFunc

ConditionIn returns a ConditionFunc that checks if the attribute value is one of the specified values.

func ConditionLessThan added in v0.1.17

func ConditionLessThan(value any) ConditionFunc

ConditionLessThan returns a ConditionFunc that checks if the attribute value is less than the specified value.

func ConditionLessThanOrEqual added in v0.1.17

func ConditionLessThanOrEqual(value any) ConditionFunc

ConditionLessThanOrEqual returns a ConditionFunc that checks if the attribute value is less than or equal to the specified value.

func ConditionNotEqual added in v0.1.17

func ConditionNotEqual(value any) ConditionFunc

ConditionNotEqual returns a ConditionFunc that checks if the attribute value is not equal to the specified value.

type FilterFunc

type FilterFunc func(string) expression.ConditionBuilder

FilterFunc returns a condition builder for a key.

func KeyBeginsWith

func KeyBeginsWith(prefix any) FilterFunc

KeyBeginsWith returns a FilterFunc that filters items based on whether the key begins with the specified prefix.

func KeyBetween

func KeyBetween(start, end any) FilterFunc

KeyBetween returns a FilterFunc that generates a condition builder for a keyName that checks if its value is between the start and end values. The start and end values can be of any type.

func KeyContains

func KeyContains(value any) FilterFunc

KeyContains returns a FilterFunc that checks if the given value is contained in the key's value.

func KeyEqual

func KeyEqual(value any) FilterFunc

KeyEqual returns a FilterFunc that filters based on the equality of a key's value.

func KeyGreaterThan

func KeyGreaterThan(value any) FilterFunc

KeyGreaterThan returns a FilterFunc that filters items based on the specified key being greater than the given value.

func KeyGreaterThanOrEqual

func KeyGreaterThanOrEqual(value any) FilterFunc

KeyGreaterThanOrEqual returns a FilterFunc that filters items where the value of the specified key is greater than or equal to the given value.

func KeyIn

func KeyIn(value any) FilterFunc

KeyIn returns a FilterFunc that checks if the given value is present in the specified keyName.

func KeyLessThan

func KeyLessThan(value any) FilterFunc

KeyLessThan returns a FilterFunc that filters items based on whether the value of the specified key is less than the given value.

func KeyLessThanOrEqual

func KeyLessThanOrEqual(value any) FilterFunc

KeyLessThanOrEqual returns a FilterFunc that filters items where the value of the specified key is less than or equal to the given value.

func KeyNotContains added in v0.1.2

func KeyNotContains(value any) FilterFunc

KeyNotContains returns a FilterFunc that filters out items where the value of the specified key does not contain the given value.

func KeyNotEqual

func KeyNotEqual(value any) FilterFunc

KeyNotEqual returns a FilterFunc that generates a condition builder for a key that is not equal to the specified value.

func KeyNotNull

func KeyNotNull() FilterFunc

KeyNotNull returns a FilterFunc that checks if the specified key is not null.

func KeyNull

func KeyNull() FilterFunc

KeyNull returns a FilterFunc that checks if the specified key does not exist in the DynamoDB item.

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item represents a DynamoDB item and provides methods to perform operations on it.

func (*Item) AddBatchDeleteItem

func (i *Item) AddBatchDeleteItem(newItem *Item)

AddBatchDeleteItem adds a new item to the batch delete list.

Example:

 item := new(Item)
 for _, gId := range gIds {
	 db.PK(gId).SK(Equal(SK)).AddBatchDeleteItem(item)
 }
 err = item.BatchDeleteItem(context.Background(), 10)

func (*Item) AddBatchGetItem

func (i *Item) AddBatchGetItem(newItem *Item, omitEmptyKeys bool)

AddBatchGetItem adds a new item to the batch get item request. If omitEmptyKeys is true empty keys will not be added to BatchGetItem. If omitEmptyKeys is false empty keys also be added to BatchGetItem.

Example:

 item := new(Item)
 for _, gId := range gIds {
	 db.PK(gId).SK(Equal(SK)).AddBatchGetItem(item, true)
 }
 output, err := item.BatchGetItem(context.Background(), 10)

func (*Item) AddBatchUpsertItem

func (i *Item) AddBatchUpsertItem(newItem *Item)

AddBatchUpsertItem adds a new item to the batch upsert operation.

Example:

 item := new(Item)
 for _, gId := range gIds {
	 db.PK(gId).SK(Equal(SK)).AddBatchUpsertItem(item)
 }
 err = item.BatchUpsertItem(context.Background(), 10)

func (*Item) AddBatchUpsertRawItem added in v0.1.9

func (i *Item) AddBatchUpsertRawItem(newItem *Item)

AddBatchUpsertRawItem adds a new raw item (types.AttributeValue) to the batch upsert operation.

Example:

newItem := new(Item)
for _, item := range items {
	db.ItemRaw(item).AddBatchUpsertRawItem(newItem)
}
// here items is of type []map[string]types.AttributeValue

err = newItem.BatchUpsertItem(context.Background(), 10)
if err != nil {
	log.Fatal(err)
}

func (*Item) AddUpdateRawItem added in v0.1.12

func (i *Item) AddUpdateRawItem(newItem *Item)

AddUpdateRawItem adds a new raw item (types.AttributeValue) to the update operation.

Example:

newItem := new(Item)
for _, item := range items {
	db.UpdateItemRaw(item).AddUpdateRawItem(newItem)
}

err = newItem.Update(context.Background(), 5)

func (*Item) AndFilter

func (i *Item) AndFilter(attributeName string, filterFunc FilterFunc) *Item

AndFilter applies an additional logical AND filter to the existing filter using the specified attribute name and filter function. It should be used after the Filter function.

Example:

 err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	Filter("physical_name", dygo.KeyBeginsWith("name_test_")).
	AndFilter("logical_name", dygo.KeyBeginsWith("name_test_")).
	GetItem(context.Background(), &data)

func (*Item) BatchDeleteItem

func (i *Item) BatchDeleteItem(ctx context.Context, threadCount int) error

BatchDeleteItem deletes multiple items in batches. It takes a context and the number of threads to use for parallel processing. It returns an error if any of the batch operations fail.

Example :

item := new(Item)
for _, gId := range gIds {
	db.PK(gId).SK(Equal(SK)).AddBatchDeleteItem(item)
}

err = item.BatchDeleteItem(context.Background(), 10)
if err != nil {
	log.Fatal(err)
}

func (*Item) BatchGetAuthorizedItem

func (i *Item) BatchGetAuthorizedItem(ctx context.Context, threadCount int) *output

BatchGetAuthorizedItem fetches multiple items from DynamoDB in parallel, with authorization. It uses a specified number of goroutines to perform the batch get operation concurrently. The fetched items are stored in the Output struct and returned as a result. Use Unmarshal() to unmarshal the results into the provided 'out' object.

Example:

func (d *dataItem) Authorize(ctx context.Context) error {
	return nil
}

item := new(Item)

for _, gId := range gIds {
	db.PK(gId).SK(Equal(SK)).AddBatchGetItem(item, true)
}

var data []dataItem
err = item.BatchGetAuthorizedItem(context.Background(), 10).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Item) BatchGetItem

func (i *Item) BatchGetItem(ctx context.Context, threadCount int) ([]map[string]types.AttributeValue, error)

BatchGetItem retrieves multiple items from the DynamoDB table in parallel using multiple threads. It takes a context and the number of threads as input parameters. It returns a slice of maps, where each map represents an item retrieved from the table, along with any error encountered.

Example:

item := new(Item)
for _, gId := range gIds {
	db.PK(gId).SK(Equal(SK)).AddBatchGetItem(item, true)
}

output, err := item.BatchGetItem(context.Background(), 10)

func (*Item) BatchUpsertItem

func (i *Item) BatchUpsertItem(ctx context.Context, threadCount int) error

BatchUpsertItem performs batch upsert operations on items. It takes a context and the number of threads to use for parallel processing. It returns an error if any of the batch operations fail.

Example :

newItem := new(Item)
for i := 0; i < 5; i++ {
	d := dataItem{
		PK:           gId,
		SK:           "current",
		PhysicalName: "physical_name_1145",
		LogicalName:  "logical_name_1145",
		EntityType:   "room",
	}
	db.Item(d).AddBatchUpsertItem(newItem)
}
err = newItem.BatchUpsertItem(context.Background(), 10)
if err != nil {
	log.Fatal(err)
}

func (*Item) Condition added in v0.1.17

func (i *Item) Condition(attributeName string, conditionFunc ConditionFunc) *Item

Condition sets condition for ConditionExpression. NOTE: It is currently supported for only Upsert operation. It takes the attribute name and condition function as parameters. Possible values for ConditionFunc are ConditionEqual, ConditionNotEqual, ConditionLessThan, ConditionLessThanEqual, ConditionGreaterThan, ConditionGreaterThanEqual, ConditionBetween, ConditionIn, ConditionAttributeExists, ConditionAttributeNotExists and ConditionBeginsWith. Example:

 err = db.
	Item(newData).
	Condition("version", ConditionEqual(10)).
	Upsert(context.Background())

func (*Item) Count added in v0.1.11

func (i *Item) Count(ctx context.Context) (int, int, error)

Count executes a query operation on the DynamoDB table and returns the total number of items and the number of items that match the query filter.

Example:

err = db.
	GSI("gsi-name", "room", Equal("current")).
	Filter("physical_name", KeyBeginsWith(prefix)).
	AndFilter("logical_name", KeyBeginsWith(prefix)).
	Count(context.Background())

OR

err = db.
	PK(PK).
	SK(Equal(SK)).
	Count(context.Background())

func (*Item) Create

func (i *Item) Create(ctx context.Context) error

Create creates a new item in DynamoDB. It validates the item using the user defined Validate() method.

Example :

newData := dataItem{
	PK:           PK,
	SK:           SK,
	EntityType:   "room",
	PhysicalName: "physical_name_11",
	LogicalName:  "logical_name_11",
}

err = db.
	Item(newData).
	Create(context.Background())

Important : dataItem must implement Validate() method.

func (*Item) Delete

func (i *Item) Delete(ctx context.Context) error

Delete deletes the item from the DynamoDB table. It returns an error if there was an issue with the deletion process.

func (*Item) Filter

func (i *Item) Filter(attributeName string, filterFunc FilterFunc) *Item

Filter applies a filter function to the specified attribute of the item. Possible values for FilterFunc are KeyEqual, KeyNotEqual, KeyBeginsWith, KeyBetween, KeyLessThan, KeyLessThanEqual, KeyGreaterThan, KeyGreaterThanEqual, KeyContains, KeyNotNull, KeyNull, KeyIn.

Example:

 err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	Filter("physical_name", dygo.KeyBeginsWith("name_test_")).
	GetItem(context.Background(), &data)

func (*Item) GetAuthorizedItem

func (i *Item) GetAuthorizedItem(ctx context.Context, out Out) error

GetAuthorizedItem retrieves an authorized item from DynamoDB based on the provided key. It performs authorization checks on the retrieved item with user defined Authorize() function before returning it. If there is an error during the retrieval or authorization process, it returns the corresponding error.

Example:

func (d *dataItem) Authorize(ctx context.Context) error {
	return nil
}
d := dataItem{}
err = db.
	PK(PK).
	SK(Equal(SK)).
	GetItem(context.Background(), &d)

func (*Item) GetItem

func (i *Item) GetItem(ctx context.Context, out interface{}) error

GetItem retrieves an item from DynamoDB based on the provided key and stores the result in the 'out' parameter. It returns an error if there was an issue with the retrieval or unmarshaling of the item.

Example:

d := dataItem{}
err = db.
	PK(PK).
	SK(Equal(SK)).
	GetItem(context.Background(), &d)

func (*Item) LastEvaluatedKey

func (i *Item) LastEvaluatedKey(keys map[string]any) *Item

LastEvaluatedKey sets the last evaluated key for pagination.

Example:

err = db.
	GSI("gsi-name", "room", Equal("current")).
	Limit(2).
	LastEvaluatedKey(lek).
	Query(context.Background()).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Item) Limit

func (i *Item) Limit(itemCount int) *Item

Limit sets the maximum number of items to be returned in the pagination.

Example:

err = db.
	GSI("gsi-name", "room", Equal("current")).
	Limit(2).
	LastEvaluatedKey(lek).
	Query(context.Background()).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Item) OrFilter

func (i *Item) OrFilter(attributeName string, filterFunc FilterFunc) *Item

OrFilter method is used to chain multiple filters together using the OR operator. It should be used after the Filter function.

Example:

 err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	Filter("physical_name", dygo.KeyBeginsWith("name_test_")).
	OrFilter("logical_name", dygo.KeyBeginsWith("name_test_")).
	GetItem(context.Background(), &data)

func (*Item) Project

func (i *Item) Project(value ...string) *Item

Project sets the projection for the item. It takes a variadic parameter `value` which represents the projection fields.

Example:

 err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	Project("_partition_key", "_entity_type", "_sort_key").
	GetItem(context.Background(), &data)

func (*Item) Query

func (i *Item) Query(ctx context.Context) *output

QueryAuthorizeItem executes a query operation on the DynamoDB table. The method returns an Output object containing the query results or an error if the query fails. Items can be retrieved from the Output object using Unmarshall().

Example:

err = db.
	GSI("gsi-name", "room", Equal("current")).
	Filter("physical_name", KeyBeginsWith(prefix)).
	AndFilter("logical_name", KeyBeginsWith(prefix)).
	Project("_partition_key", "_entity_type", "_sort_key", "physical_name", "logical_name").
	Limit(2).
	LastEvaluatedKey(lek).
	Query(context.Background()).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Item) SK

func (i *Item) SK(f SortKeyFunc) *Item

SK sets the provided sort key value along with SortKeyFunc. The SortKeyFunc is used to determine the sorting order of the Item. Possible values for SortKeyFunc are Equal, BeginsWith, Between, LessThan, LessThanEqual, GreaterThan, GreaterThanEqual.

Example:

 err = db.
	PK("pk").
	SK(dygo.Equal("sk")).
	GetItem(context.Background(), &data)

func (*Item) ScanIndexForward added in v0.1.2

func (i *Item) ScanIndexForward(value bool) *Item

ScanIndexForward sets the flag indicating whether the scan operation should be performed in ascending order. If value is true, the scan will be performed in ascending order. If value is false, the scan will be performed in descending order.

Example:

 err = db.
	GSI("gsi-name", "room", dygo.Equal("current")).
	ScanIndexForward(true).
	Query(context.Background()).
	Unmarshal(&data, []string{"room"}).
	Run()

func (*Item) Update added in v0.1.12

func (i *Item) Update(ctx context.Context, n int) error

func (*Item) Upsert

func (i *Item) Upsert(ctx context.Context) error

Upsert updates or inserts an item into the DynamoDB table. It validates the item using user provided function, marshals it into a map using JSON tags, and then performs a PutItem operation on the DynamoDB table. If any error occurs during the process, it returns an error.

type ItemData

type ItemData interface {
	Validate() error
}

ItemData is an interface that represents a DynamoDB item. Each data item must implement this interface. It is used to validate the item using user defined Validate function before performing any operations on it.

type Option

type Option func(*Client) error

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint is an optional option function that sets the endpoint for the client. It takes an endpoint string as a parameter and returns an error.

func WithGSI

func WithGSI(indexName, partitionKey, sortKey string) Option

WithGSI is an optional option function that adds a Global Secondary Index (GSI) to the client. It takes the index name, partition key, and sort key as parameters. If a GSI with the same index name already exists, it returns an error. Otherwise, it adds the GSI to the client and returns nil.

func WithKeySeparator added in v0.1.1

func WithKeySeparator(separator string) Option

WithKeySeparator sets the key separator for the client. The key separator is used to separate different parts of partition key in the client.

func WithLogger

func WithLogger(l *log.Logger) Option

WithLogger is an optional option function that sets the logger for the client. It takes a *log.Logger as a parameter and returns an error. The logger will be used to log client operations and errors.

func WithPartitionKey

func WithPartitionKey(key string) Option

WithPartitionKey is a mandatory option function that sets the partition key for the client. It takes a string parameter 'key' and returns an error.

func WithProfile added in v0.1.20

func WithProfile(profile string) Option

WithProfile is a mandatory option function that sets the profile for the client. It takes a profile string as a parameter and returns an error.

func WithRegion

func WithRegion(region string) Option

WithRegion is a mandatory option function that sets the region for the client. It takes a string parameter representing the region and returns an error. The region is used to configure the client for a specific geographic region.

func WithRetry

func WithRetry(count int) Option

WithRetry is an optional option function that sets the maximum number of retries for a client. It takes an integer count as a parameter and returns an error. The count parameter specifies the maximum number of retries allowed. If the count is not provided, it defaults to 5.

func WithSortKey

func WithSortKey(key string) Option

WithSortKey is an optional option function that sets the sort key for the client. Example:

client := NewClient(WithSortKey("sk"))
// This sets the sort key to "sk" for the client.

func WithTableName

func WithTableName(tableName string) Option

WithTableName is a mandatory option function that sets the table name for the client. It takes a tableName string as a parameter and returns an error.

type Out

type Out interface {
	Authorize(context.Context) error
}

Out is an interface that must be implemented by the struct that is used to unmarshal the DynamoDB results. It has a Authorize method that is used to perform authorization on the retrieved items.

type SortKeyFunc

type SortKeyFunc func(string) (expression.KeyConditionBuilder, any)

SortKeyFunc returns a KeyConditionBuilder and a value of any type.

func BeginsWith

func BeginsWith(prefix any) SortKeyFunc

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. The prefix value should be of type string.

func Between

func Between(start, end any) SortKeyFunc

Between is a function that returns a SortKeyFunc which represents a key condition builder for the BETWEEN condition in DynamoDB. It takes two parameters, start and end, of any type. The SortKeyFunc returned by Between can be used to create a key condition builder for a specific key name. The start value is inclusive and the end value is exclusive in the BETWEEN condition.

func Equal

func Equal(value any) SortKeyFunc

Equal returns a SortKeyFunc that generates a KeyConditionBuilder for the "Equal" condition. The generated KeyConditionBuilder checks if the value of the specified key is equal to the given value. It takes a value of any type as a parameter and returns a function that accepts a key name.

func GreaterThan

func GreaterThan(value any) SortKeyFunc

GreaterThan returns a SortKeyFunc that generates a KeyConditionBuilder for a greater than condition. The SortKeyFunc takes a value of any type and returns a function that accepts a keyName string.

func GreaterThanOrEqual

func GreaterThanOrEqual(value any) SortKeyFunc

GreaterThanOrEqual returns a SortKeyFunc that generates a KeyConditionBuilder for a greater than or equal condition. The generated KeyConditionBuilder compares the specified keyName with the given value and returns items where the key value is greater than or equal to the specified value.

func LessThan

func LessThan(value any) SortKeyFunc

LessThan returns a SortKeyFunc that generates a KeyConditionBuilder for a less than condition. The generated KeyConditionBuilder compares the specified keyName with the given value using the LessThan operator. The value parameter represents the value to compare against.

func LessThanOrEqual

func LessThanOrEqual(value any) SortKeyFunc

LessThanOrEqual returns a SortKeyFunc that generates a KeyConditionBuilder for a less than or equal to comparison. The generated KeyConditionBuilder compares the given keyName with the provided value using the LessThanEqual method of the expression package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL