dbx

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DBXContext   ContextKey = "dbx-context"
	SQLLiteType             = "sqllite"
	MysqlType               = "mysql"
	PostgresType            = "postgres"
	DB           *gorm.DB
)

Functions

func FromCtx

func FromCtx(ctx context.Context) *gorm.DB

func Init

func Init(c *Config)

func InjectCtx

func InjectCtx(ctx context.Context, db *gorm.DB) context.Context

func Migrate

func Migrate(ctx context.Context, tenants ...string)

func RegisterModel

func RegisterModel(m interface{})

func SessionCtx

func SessionCtx(ctx context.Context) context.Context

func SessionHandler

func SessionHandler(next http.Handler) http.Handler

func WithTenant

func WithTenant(tenant string, m interface{}) func(db *gorm.DB) *gorm.DB

Types

type Config

type Config struct {
	Type        string
	DSN         string
	TablePrefix string
	MaxIdleConn int
	MaxOpenConn int
	Logger      logrus.FieldLogger
}

type ContextKey

type ContextKey string

type Model

type Model struct {
	ID        uint64 `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Jump to

Keyboard shortcuts

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