model

package module
v0.0.0-...-e1ce254 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: MIT Imports: 13 Imported by: 0

README

cola-model

Coke web framework uses gorm (gorm.io) middleware

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

type JSON json.RawMessage

JSON Custom json field

func (JSON) GormDBDataType

func (JSON) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType schema.Field DataType

func (*JSON) Scan

func (j *JSON) Scan(src interface{}) error

Scan sql.Scanner interface

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value driver.Valuer interface, Value return json value

type Model

type Model struct {
	ID        uid.UID         `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time       `gorm:"<-:create" json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
	DeletedAt *gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

Model base model with uid(github.com/xs23933/uid)

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) error

BeforeCreate enhancing ID

type Models

type Models struct {
	*gorm.DB
	Driver string `yaml:"driver"`
	DSN    string `yaml:"dsn"`
}

Models models

func (*Models) Connect

func (m *Models) Connect()

Connect Init DB connect

func (Models) Module

func (Models) Module() cola.ModuleInfo

Module module interface

Jump to

Keyboard shortcuts

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