output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel added in v0.0.10

func Camel(s string) string

camel is a modified Title function from package strings, converting to CamelCase. see isSeperator for conversion rules.

func Copy added in v0.0.10

func Copy(s string) string

Types

type Column

type Column struct {
	schema.Column
	// contains filtered or unexported fields
}

Column represents a database table for purposes of code generation.

func NewColumn

func NewColumn(c schema.Column, nameFunc NameFunc, quoteFunc QuoteFunc, joinFunc JoinFunc) Column

NewColumn creates a new Column from a schema.Column.

func (Column) GoName

func (c Column) GoName() string

func (Column) QualifiedName added in v0.1.0

func (c Column) QualifiedName() string

func (Column) QuotedName added in v0.1.0

func (c Column) QuotedName() string

func (Column) ValueSuffix added in v0.0.8

func (c Column) ValueSuffix() string

ValueSuffix returns the string which has to be appended to the name to access it's value, eg. ".Bool" for sql.NullBool

func (Column) ValueType added in v0.0.8

func (c Column) ValueType() reflect.Type

type Foreign added in v0.0.2

type Foreign struct {
	schema.Foreign
	Child         Table
	ChildColumns  []Column
	Parent        Table
	ParentColumns []Column
	References    []Reference
	// contains filtered or unexported fields
}

Foreign represents a foreign constraint for purposes of code generation.

func NewForeign added in v0.0.2

func NewForeign(f schema.Foreign, nameFunc NameFunc, quoteFunc QuoteFunc, joinFunc JoinFunc) Foreign

NewForeign creates a new Foreign from a schema.Foreign

func (Foreign) GoName added in v0.0.2

func (f Foreign) GoName() string

func (Foreign) QuotedName added in v0.1.0

func (f Foreign) QuotedName() string

type JoinFunc added in v0.1.0

type JoinFunc func([]string) string

type NameFunc added in v0.0.10

type NameFunc func(string) string

type Output added in v0.0.2

type Output struct {
	PackageTmpl   *template.Template
	TableTmpl     *template.Template
	ScanFromTmpl  *template.Template
	CloneTmpl     *template.Template
	SelectTmpl    *template.Template
	InsertTmpl    *template.Template
	FindTmpl      *template.Template
	UpdateTmpl    *template.Template
	DeleteTmpl    *template.Template
	ProcedureTmpl *template.Template
	ViewTmpl      *template.Template
	ForeignTmpl   *template.Template
	// contains filtered or unexported fields
}

Output generates Go code from gathered DB information.

Output-values should be created using NewOutput. The members holding the templates can be modified afterwards, to permit usage of custom templates.

func NewOutput added in v0.0.2

func NewOutput(pkg string, tables []Table, procedures []Procedure, views []Table) *Output

NewOutput creates a new initialized Output.

pkg is inserted as package name into the generated code. an example of how to generate an appropriate tables slice can be found in the command rom.

func (Output) Execute added in v0.0.2

func (o Output) Execute(w io.Writer, tables bool, methods bool, primary bool, foreign bool, procedures bool, views bool) error

Execute generates Go-code for database access.

w specifies where code is written to, the boolean arguments select if code is generated for table types, methods to access the database, methods to access the database by primary key and methods to access the database by foreign key (currently unimplemented).

type Parameter added in v0.0.4

type Parameter struct {
	schema.Parameter
}

Parameter represents a parameter to a stored procedure.

func (Parameter) GoName added in v0.0.4

func (p Parameter) GoName() string

type Procedure added in v0.0.4

type Procedure struct {
	schema.Procedure
	Parameters []Parameter
	// contains filtered or unexported fields
}

Procedure represents data about a stored procedure.

func NewProcedure added in v0.0.4

func NewProcedure(p schema.Procedure, nameFunc NameFunc, quoteFunc QuoteFunc, joinFunc JoinFunc) Procedure

func (Procedure) GoName added in v0.0.4

func (p Procedure) GoName() string

func (Procedure) In added in v0.0.4

func (p Procedure) In() []Parameter

In returns all parameters of a stored procedure declared as IN.

func (Procedure) Out added in v0.0.4

func (p Procedure) Out() []Parameter

Out returns all parameters of a stored procedure declared as OUT.

func (Procedure) QualifiedName added in v0.1.0

func (p Procedure) QualifiedName() string

func (Procedure) QuotedName added in v0.1.0

func (p Procedure) QuotedName() string

type QuoteFunc added in v0.1.0

type QuoteFunc func(string) string

type Reference added in v0.0.8

type Reference struct {
	Referencing Column
	Referenced  Column
}

Reference represents a column mapping of a foreign constraint for purposes of code generation.

type Table

type Table struct {
	schema.Table
	Columns []Column
	Primary []Column
	Foreign []Foreign
	Imports []string
	// contains filtered or unexported fields
}

Table represents a database table for purposes of code generation. It is acting as collection of all data about a table and it's columns.

func NewTable

func NewTable(st schema.Table, cs []schema.Column, ps []schema.Column, fs []schema.Foreign, nameFunc NameFunc, quoteFunc QuoteFunc, joinFunc JoinFunc) Table

NewTable creates a new Table from values collected from the database.

func (Table) GoName

func (t Table) GoName() string

func (Table) QualifiedName added in v0.1.0

func (t Table) QualifiedName() string

func (Table) QuotedName added in v0.1.0

func (t Table) QuotedName() string

Jump to

Keyboard shortcuts

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