pg

package
v0.0.0-...-6a21e17 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PG

type PG struct {
	TableName  string
	PkgName    string
	SkipSuffix bool
	// contains filtered or unexported fields
}

PG generates the CRUD methods for Postgresql using lib/pg.

func New

func New(pkg *types.Package, t *types.Struct, structModel string) (*PG, error)

New returns a PG

func (*PG) Format

func (g *PG) Format() ([]byte, error)

Format returns the gofmt-ed contents of the PG's buffer.

func (*PG) Generate

func (g *PG) Generate(w io.Writer, fns ...generator.Function) error

Generate generates CRUD code for the passed in functions

func (*PG) GenerateCreate

func (g *PG) GenerateCreate()

GenerateCreate generates the Create method for the struct

func (*PG) GenerateDelete

func (g *PG) GenerateDelete()

GenerateDelete generates the Delete method for the struct

func (*PG) GenerateGet

func (g *PG) GenerateGet()

GenerateGet generates the Get method for the struct

func (*PG) GenerateList

func (g *PG) GenerateList()

GenerateList generates the Get method for the struct

func (*PG) GenerateType

func (g *PG) GenerateType(t cruderType)

GenerateType adds the cruderType to the header buffer. It keeps track of whether the type is generated or not and thus can be called multiple times safely.

func (*PG) GenerateUpdate

func (g *PG) GenerateUpdate()

GenerateUpdate generates the Update method for the struct

func (*PG) HeaderPrintf

func (g *PG) HeaderPrintf(in string, args ...interface{})

HeaderPrintf writes the input to the PG's header buffer

func (*PG) Printf

func (g *PG) Printf(in string, args ...interface{})

Printf writes the input to the PG's body buffer

func (*PG) SetPrimaryField

func (g *PG) SetPrimaryField(f string) error

SetPrimaryField sets the field that are used as primary key in lookups

func (*PG) SetReadFields

func (g *PG) SetReadFields(fields []string) error

SetReadFields sets the fields that should be returned in reading operations. The passed in slice will be match against the fieldnames of the struct

func (*PG) SetSoftDeleteField

func (g *PG) SetSoftDeleteField(f string) error

SetSoftDeleteField sets the field that should be used for soft deletion. The field should be of type nullable datetime but this function does not check that.

func (*PG) SetWriteFields

func (g *PG) SetWriteFields(fields []string) error

SetWriteFields sets the fields that should be returned in writing operations. The passed in slice will be match against the fieldnames of the struct

func (*PG) String

func (g *PG) String() string

String output all buffers as string

Jump to

Keyboard shortcuts

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