codegen

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoField

type GoField struct {
	Name string
	Type GoType
	Tags string
}

GoField - a struct field.

func NewGoField

func NewGoField(nm string, t GoType, tags string) GoField

func (GoField) String

func (g GoField) String() string

type GoStruct

type GoStruct struct {
	Name     string
	Fields   []GoField
	Comments string
}

GoStruct - a go struct.

func (GoStruct) ArglistFunc

func (g GoStruct) ArglistFunc() string

ArglistFunc - return a function that generates an argument list.

func (GoStruct) IsEmpty

func (g GoStruct) IsEmpty() bool

func (GoStruct) KeyFunc

func (g GoStruct) KeyFunc(prefix string) string

KeyFunc - return a key func of go struct.

func (GoStruct) ScanFunc

func (g GoStruct) ScanFunc() string

ScanFunc - return a simple func string of sql scan.

func (GoStruct) String

func (g GoStruct) String() string

type GoType

type GoType struct {
	Pkg       string
	ID        string
	IsPointer bool
	IsList    bool
}

GoType - a simple type in go. If both pointer and list, it represents []*T, not *[]T, i.e. nullability is on the inner type.

func (GoType) String

func (g GoType) String() string

type InvalidateTemplate

type InvalidateTemplate struct {
	ArgName       string
	ValName       string
	CacheDuration time.Duration
}

InvalidateTemplate - the invalidate piece in function

type LoadDumpFunc added in v0.4.1

type LoadDumpFunc struct {
	TableName  string
	Columns    []string
	PrimaryKey []string
}

func (LoadDumpFunc) InsertSQL added in v0.4.1

func (l LoadDumpFunc) InsertSQL() string

func (LoadDumpFunc) SelectSQL added in v0.4.1

func (l LoadDumpFunc) SelectSQL() string

type LoadDumpFuncTemplate added in v0.4.1

type LoadDumpFuncTemplate struct {
	RepoName       string
	MainStructName string
	SelectAllSQL   string
	InsertRowSQL   string
}

LoadDumpFuncTemplate - the load and dump functions.

func (LoadDumpFuncTemplate) Generate added in v0.4.1

func (l LoadDumpFuncTemplate) Generate() (string, error)

Generate string template

type MutationFunc

type MutationFunc struct {
	Name        string
	SQL         string
	Input       *GoStruct
	Invalidates []*QueryFunc
}

MutationFunc - a query function

func (MutationFunc) Signature

func (m MutationFunc) Signature() string

Signature returns the type signature of the mutation, exposed to user. Invalidates are explicitly named in signatures.

type MutationFuncTemplate

type MutationFuncTemplate struct {
	RepoName     string
	MutationName string
	MutationSig  string
	SQLVarName   string
	Invalidates  []InvalidateTemplate
}

MutationFuncTemplate - the mutation function.

func (MutationFuncTemplate) Generate

func (q MutationFuncTemplate) Generate() (string, error)

Generate string template

type QueryFunc

type QueryFunc struct {
	Name          string
	SQL           string
	CacheDuration *time.Duration
	Input         *GoStruct
	Output        *GoStruct
	IsList        bool
}

QueryFunc - a query function

func (QueryFunc) ReturnType

func (q QueryFunc) ReturnType() string

ReturnType of the query func

func (QueryFunc) Signature

func (q QueryFunc) Signature() string

Signature returns the type signature of the query function, exposed to user.

func (QueryFunc) SignatureInnerFunc

func (q QueryFunc) SignatureInnerFunc() string

SignatureInnerFunc returns the type signature of the inner query function.

type QueryFuncTemplate

type QueryFuncTemplate struct {
	RepoName        string
	QueryName       string
	QueryInnerSig   string
	QuerySig        string
	HiddenQueryName string
	RstTypeName     string
	CacheDuration   *time.Duration // nil = nocache, 0s = forever.
	SQLVarName      string
	IsList          bool
	InitArgsType    string // init a empty args in the ourter func, if not empty string.
}

QueryFuncTemplate - the query function.

func (QueryFuncTemplate) Generate

func (q QueryFuncTemplate) Generate() (string, error)

Generate string template

type RepoTemplate

type RepoTemplate struct {
	NeedleVersion       string
	TableSchema         string
	PkgName             string
	InterfaceName       string
	InterfaceSignatures []string
	RepoName            string
	MainStruct          string
	MainStructName      string
	LoadDump            string
	Statements          []SQLStatementDecl
	Queries             []string
	Mutations           []string
}

RepoTemplate template for render a repo.

func (RepoTemplate) Generate

func (q RepoTemplate) Generate() (string, error)

Generate string template

type SQLStatementDecl

type SQLStatementDecl struct {
	VarName    string
	EscapedSQL string
}

SQL statements

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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