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" // Package for model files Pkg = "pkg" )
Variables ¶
This section is empty.
Functions ¶
func CreateCommand ¶
CreateCommand creates cobra command
Types ¶
type Gen ¶
type Gen interface { AddFlags(command *cobra.Command) ReadFlags(command *cobra.Command) error Generate() error }
Gen is interface for all generators
type Generator ¶
Generator is base generator used in other generators
func NewGenerator ¶
NewGenerator creates generator
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 // Package sets package name for model // Works only with SchemaPackage = false Package string // Do not replace primary key name to ID KeepPK bool // Soft delete column SoftDelete string // use sql.Null... instead of pointers UseSQLNulls bool // Do not generate alias tag NoAlias bool // Do not generate discard_unknown_columns tag NoDiscard bool // Override type for json/jsonb JSONTypes map[string]string // Add json tag to models AddJSONTag bool // Generate basic ORM queries WithORM bool // Generate Search queries WithSearch bool // Generate Vallidation functions WithValidation bool // Strict types in filters Relaxed bool // Struct name for ORM queries. Works only when GenORM == true DBWrapName string // Custom types goes here CustomTypes model.CustomTypeMapping }
Options is common options for all generators
Click to show internal directories.
Click to hide internal directories.