base

package
v0.0.0-...-45b908b Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Conn is connection string (-c) basic flag
	Conn = "conn"

	// Output is output filename (-o) basic flag
	Output = "output"

	// Tables is basic flag (-t) for tables to generate
	Tables = "tables"

	// FollowFKs is basic flag (-f) for generate foreign keys models for selected tables
	FollowFKs = "follow-fk"
)

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(command *cobra.Command)

AddFlags adds basic flags to command

func CreateCommand

func CreateCommand(name, description string, generator Gen) *cobra.Command

CreateCommand creates cobra command

func ReadFlags

func ReadFlags(command *cobra.Command) (conn, output string, tables []string, followFKs bool, err error)

ReadFlags reads basic flags from command

Types

type Gen

type Gen interface {
	Logger() *zap.Logger

	AddFlags(command *cobra.Command)
	ReadFlags(command *cobra.Command) error

	Generate() error
}

Gen is interface for all generators

type Generator

type Generator struct {
	genna.Genna
}

Generator is base generator used in other generators

func NewGenerator

func NewGenerator(url string, log *zap.Logger) Generator

NewGenerator creates generator

func (Generator) Generate

func (g Generator) Generate(tables []string, followFKs, useSQLNulls bool, output, tmpl string, packer Packer) error

Generate runs whole generation process

func (Generator) GenerateFromEntities

func (g Generator) GenerateFromEntities(entities []model.Entity, output, tmpl string, packer Packer) error

type Options

type Options struct {
	// URL connection string
	URL string

	// Output file path
	Output string

	// List of Tables to generate
	// Default []string{"public.*"}
	Tables []string

	// Generate model for foreign keys,
	// even if Tables not listed in Tables param
	// will not generate fks if schema not listed
	FollowFKs bool
}

Options is common options for all generators

func (*Options) Def

func (o *Options) Def()

Def sets default options if empty

type Packer

type Packer func(entities []model.Entity) (interface{}, error)

Packer is a function that compile entities to package

Jump to

Keyboard shortcuts

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