dynamobind

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package dynamobind parses and prints typed DynamoDB access-pattern sources.

The grammar is its own: a declaration takes its Go visibility from the case of its name, where an HTML or SQL template takes it from an export keyword. The two are therefore not one grammar wearing two hats, and this package stays separate from the shared template parser until that difference is settled on purpose rather than by a move.

Index

Constants

View Source
const DefaultTemplatePattern = "*.tb.dynamo"

DefaultTemplatePattern is the base-name glob for query declarations, beside the HTML and SQL template patterns.

Variables

This section is empty.

Functions

func Format

func Format(filename string, source []byte, options syntax.PrintOptions) ([]byte, error)

Format lays out one .tb.dynamo source. A source that does not parse is reported rather than guessed at, so the caller can leave the file untouched.

Types

type Op

type Op string

Op is a key condition operator.

const (
	OpEqual          Op = "="
	OpLess           Op = "<"
	OpLessOrEqual    Op = "<="
	OpGreater        Op = ">"
	OpGreaterOrEqual Op = ">="
	OpBetween        Op = "between"
	OpBeginsWith     Op = "begins_with"
)

type Predicate

type Predicate struct {
	Attribute string
	Op        Op
	Params    []string
	Line      int
}

Predicate is one comparison in a key clause. Params holds one name, or two for BETWEEN.

type QueryDecl

type QueryDecl struct {
	Name     string
	Exported bool
	Params   []QueryParam
	Shape    ResultShape
	ItemType string
	// Table is the declared table name. It is required: an access pattern names
	// exactly one table, so the fact is complete where it is written and the
	// generated function needs no table parameter.
	Table      string
	TableLine  int
	Key        []Predicate
	SourcePath string
	Line       int
}

QueryDecl is one declared access pattern.

func ParseQueries

func ParseQueries(path string, source []byte) ([]QueryDecl, error)

ParseQueries reads every declaration in one .tb.dynamo source.

type QueryParam

type QueryParam struct {
	Name string
	// Type is the Go type as the declaration spells it, checked later against
	// the attribute's own Go type.
	Type string
	Line int
}

QueryParam is one declared parameter of a query function.

type ResultShape

type ResultShape string

ResultShape is what a declaration asks the generated function to return. It selects the request shape rather than a row count: a Query always returns many, and the choice is whether the caller sees the page boundaries.

const (
	// Page issues one request and returns a page.
	Page ResultShape = "page"
	// Many iterates every page.
	Many ResultShape = "many"
)

Jump to

Keyboard shortcuts

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