dynexpr

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT

README

GitHub Workflow Status Code Coverage Go Report Card Go Version PkgGoDev

Dynexpr

Expression builder for dynamo DB.

Install

go get github.com/gauxs/dynexpr && go install github.com/gauxs/dynexpr/...@latest

Note: Dynexpr uses Go Modules to manage dependencies.

What is Dynexpr?

Dynexpr simplifies the creation of DynamoDB expressions by performing code generation on Go structs representing DynamoDB items. It offers convenient methods to generate expressions for DynamoDB, streamlining the process of building complex queries.

Usage

Con

// dynexpr:generate
type Transaction struct {
	UserID        *string `json:"user_id,omitempty" dynexpr:"partitionKey"`
	TransactionID *string `json:"transaction_id,omitempty"  dynexpr:"sortKey"`
	Amount        *int    `json:"amount,omitempty"`
}

Configurations

  1. dynexpr:generate: should be declared over the struct which represents a single item of dynamoDB.
// dynexpr:generate
type DDBItem struct {
    ...
}
  1. dynexpr:"partitionKey": to declare that the attribute is partion key of the dynamoDB item.
type DDBItem struct {
    PK          *string       `json:"pk,omitempty" dynexpr:"partitionKey"`
    ...
}
  1. dynexpr:"sortKey": to declare that the attribute is sort key of the dynamoDB item.
type DDBItem struct {
    SK          *string       `json:"sk,omitempty" dynexpr:"sortKey"`
    ...
}

Q & A

Is this fit for your usecase?

License

The project is licensed under the MIT License.

Test

go run cmd/main.go -output_filename test/expression/data/person_dynexpr.go test/expression/data

Directories

Path Synopsis
internal
bootstrap
Package bootstrap implements the bootstrapping logic: generation of a .go file to launch the actual generator and launching the generator itself.
Package bootstrap implements the bootstrapping logic: generation of a .go file to launch the actual generator and launching the generator itself.
pkg
v1
v2
test

Jump to

Keyboard shortcuts

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