export

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeInt       = newType([]string{"int"}, "int")
	TypeString    = newType([]string{"string", "text"}, "string")
	TypeTimestamp = newType([]string{"timestamp", "datetime"}, "time.Time", &GoImport{Type: ImportTypeInternal, Value: "time"})
	TypeUUID      = newType([]string{"uuid"}, "uuid.UUID", &GoImport{Type: ImportTypeExternal, Value: "github.com/google/uuid"})
)

Functions

This section is empty.

Types

type Args

type Args struct {
	Models  Models   `json:"models"`
	Modules []string `json:"-"`
}

func (*Args) HasModule

func (a *Args) HasModule(key string) bool

type Block

type Block struct {
	Key   string   `json:"key"`
	Type  string   `json:"type"`
	Lines []string `json:"lines"`
}

func NewBlock

func NewBlock(k string, t string) *Block

func (*Block) Priority

func (b *Block) Priority() int

func (*Block) Render

func (b *Block) Render() string

func (*Block) W

func (b *Block) W(l string, args ...interface{})

type Blocks

type Blocks []*Block

type Column

type Column struct {
	Name string `json:"name"`
	Type *Type  `json:"type"`
	PK   bool   `json:"pk,omitempty"`
}

type Columns

type Columns []*Column

func (Columns) Args

func (c Columns) Args() string

func (Columns) Names

func (c Columns) Names() []string

func (Columns) PKs

func (c Columns) PKs() Columns

func (Columns) Refs

func (c Columns) Refs() string

func (Columns) Smushed

func (c Columns) Smushed() string

func (Columns) Types

func (c Columns) Types() Types

func (Columns) WhereClause

func (c Columns) WhereClause() interface{}

type GoFile

type GoFile struct {
	Package string    `json:"package,omitempty"`
	Path    []string  `json:"path,omitempty"`
	Name    string    `json:"name"`
	Imports GoImports `json:"imports"`
	Blocks  Blocks    `json:"blocks"`
}

func NewGoFile

func NewGoFile(pkg string, path []string, fn string) *GoFile

func (*GoFile) AddBlocks

func (f *GoFile) AddBlocks(b ...*Block)

func (*GoFile) AddImport

func (f *GoFile) AddImport(t GoImportType, v string)

func (*GoFile) Render

func (f *GoFile) Render() *file.File

type GoImport

type GoImport struct {
	Type  GoImportType
	Value string
}

type GoImportType

type GoImportType string
const (
	ImportTypeInternal GoImportType = "internal"
	ImportTypeExternal GoImportType = "external"
	ImportTypeApp      GoImportType = "app"
)

type GoImports

type GoImports []*GoImport

func (GoImports) Add

func (i GoImports) Add(imports ...*GoImport) GoImports

func (GoImports) ByType

func (i GoImports) ByType(t GoImportType) []string

func (GoImports) Render

func (i GoImports) Render() string

type Model

type Model struct {
	Key     string  `json:"key"`
	Pkg     string  `json:"pkg"`
	Columns Columns `json:"columns"`
}

type Models

type Models []*Model

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(logger *zap.SugaredLogger) *Service

func (*Service) Export

func (s *Service) Export(args *Args) (file.Files, error)

type Type

type Type struct {
	Keys    []string
	Go      string
	Imports GoImports
}

func TypeFromString

func TypeFromString(s string) (*Type, error)

func (*Type) MarshalJSON

func (t *Type) MarshalJSON() ([]byte, error)

func (*Type) String

func (t *Type) String() string

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) error

type Types

type Types []*Type

func (Types) GoKeys

func (t Types) GoKeys() []string

func (Types) Imports

func (t Types) Imports() GoImports

func (Types) MaxGoKeyLength

func (t Types) MaxGoKeyLength() int

Jump to

Keyboard shortcuts

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