gormschema

package
v0.0.0-...-0d3c0e5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateStmt

func CreateStmt(stmt string) interface {
	ViewOption
	TriggerOption
}

CreateStmt accepts raw SQL to create a view or trigger

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

type Option func(*Loader)

Option configures the Loader.

func WithConfig

func WithConfig(cfg *gorm.Config) Option

WithConfig sets the gorm config.

func WithJoinTable

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

WithJoinTable sets up a join table for the given model and field. Deprecated: put the join tables alongside the models in the Load call.

type Trigger

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

Trigger defines a trigger.

func NewTrigger

func NewTrigger(opts ...TriggerOption) Trigger

NewTrigger receives a list of TriggerOption to build a Trigger.

type TriggerOption

type TriggerOption interface {
	// contains filtered or unexported methods
}

TriggerOption implemented by TRIGGER's related options

type ViewDefiner

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

ViewDefiner defines a view.

type ViewOption

type ViewOption interface {
	// contains filtered or unexported methods
}

ViewOption implemented by VIEW's related options

func BuildStmt

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

Jump to

Keyboard shortcuts

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