core

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoubleSlashComment

func DoubleSlashComment(f string) string

func ExecCommand

func ExecCommand(t TmplCtx, q Query) string

func Format

func Format(s string) string

func Imports

func Imports(filename string, pkgName string) []string

func LowerTitle

func LowerTitle(f string) string

func Offset

func Offset(v int) int

Types

type Config

type Config struct {
	Package                     string   `json:"namespace"`
	EmitExactTableNames         bool     `json:"emit_exact_table_names"`
	Async                       bool     `json:"async"`
	EmitClasses                 bool     `json:"emit_classes"`
	TypeAffinity                bool     `json:"type_affinity" default:"true"`
	InflectionExcludeTableNames []string `json:"inflection_exclude_table_names"`
}

func MakeConfig

func MakeConfig(req *plugin.Request) (Config, error)

func (Config) MarshalEasyJSON

func (v Config) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Config) MarshalJSON

func (v Config) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Config) UnmarshalEasyJSON

func (v *Config) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Config) UnmarshalJSON

func (v *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Constant

type Constant struct {
	Name  string
	Type  string
	Value string
}

type Enum

type Enum struct {
	Name      string
	Comment   string
	Constants []Constant
}

func BuildEnums

func BuildEnums(req *plugin.CodeGenRequest) []Enum

type Field

type Field struct {
	ID      int
	Name    string
	Type    fsType
	Comment string
}

type Importer

type Importer struct {
	Settings    *plugin.Settings
	DataClasses []Struct
	Enums       []Enum
	Queries     []Query
}
var DefaultImporter *Importer

func (*Importer) Imports

func (i *Importer) Imports(filename string, pkgName string) []string

type Params

type Params struct {
	Struct *Struct
	// contains filtered or unexported fields
}

func (Params) Args

func (v Params) Args() string

func (Params) Bindings

func (v Params) Bindings(engine string) []string

type Query

type Query struct {
	ClassName    string
	Cmd          string
	Comments     []string
	MethodName   string
	FieldName    string
	ConstantName string
	SQL          string
	SourceName   string
	Ret          QueryValue
	Arg          Params
}

A struct used to generate methods and fields on the Queries struct

func BuildQueries

func BuildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error)

type QueryValue

type QueryValue struct {
	Emit   bool
	Name   string
	Struct *Struct
	Typ    fsType
}

func (QueryValue) EmitStruct

func (v QueryValue) EmitStruct() bool

func (QueryValue) IsStruct

func (v QueryValue) IsStruct() bool

func (QueryValue) Type

func (v QueryValue) Type() string

type Struct

type Struct struct {
	Table   plugin.Identifier
	Name    string
	Fields  []Field
	Comment string
}

func BuildDataClasses

func BuildDataClasses(conf Config, req *plugin.CodeGenRequest) []Struct

type TmplCtx

type TmplCtx struct {
	Q           string
	Package     string
	Enums       []Enum
	DataClasses []Struct
	Queries     []Query
	Settings    *plugin.Settings
	SqlcVersion string
	// TODO: Race conditions
	SourceName string

	Configuration       Config
	EmitJSONTags        bool
	EmitPreparedQueries bool
	EmitInterface       bool
}

func (TmplCtx) ConnPipeline

func (t TmplCtx) ConnPipeline(q Query) []string

provide initial connection string

func (TmplCtx) ConnString

func (t TmplCtx) ConnString() []string

provide initial connection string

func (TmplCtx) ExtraModels

func (v TmplCtx) ExtraModels() []string

func (TmplCtx) ReaderSet

func (v TmplCtx) ReaderSet() []string

Jump to

Keyboard shortcuts

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