gormschema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

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

Loader is a Loader for gorm schema.

func New

func New(dialect string, opts ...Option) *Loader

New returns a new Loader.

func (*Loader) Load

func (l *Loader) Load(models ...any) (string, error)

Load loads the models and returns the DDL statements representing the schema.

type Option added in v0.1.1

type Option func(*Loader)

Option configures the Loader.

func WithConfig added in v0.1.1

func WithConfig(cfg *gorm.Config) Option

WithConfig sets the gorm config.

func WithJoinTable added in v0.3.4

func WithJoinTable(model any, field string, jointable any) Option

WithJoinTable sets up a join table for the given model and field.

type ViewDefiner added in v0.4.0

type ViewDefiner interface {
	ViewDef(dialect string) []ViewOption
}

ViewDefiner defines a view.

type ViewOption added in v0.4.0

type ViewOption func(*viewBuilder)

ViewOption configures a viewBuilder.

func BuildStmt added in v0.4.0

func BuildStmt(fn func(db *gorm.DB) *gorm.DB) ViewOption

BuildStmt accepts a function with gorm query builder to create a CREATE VIEW statement. With this option, the view's name will be the same as the model's table name

func CreateStmt added in v0.4.0

func CreateStmt(stmt string) ViewOption

CreateStmt accepts raw SQL to create a CREATE VIEW statement.

Jump to

Keyboard shortcuts

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