model

package
v6.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package model 管理数据模型

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetOCC

func SetOCC(m *core.Model, c *Column, vals []string) error

occ

func SetPK

func SetPK(m *core.Model, col *Column, vals []string) error

pk

Types

type Column

type Column struct {
	*core.Column
	GoType reflect.Type
}

func NewColumn

func NewColumn(field reflect.StructField) (*Column, error)

func (*Column) ParseTags

func (col *Column) ParseTags(m *core.Model, tag string) (err error)

func (*Column) SetAI

func (col *Column) SetAI(m *core.Model, vals []string) error

ai

func (*Column) SetDefault

func (col *Column) SetDefault(vals []string) error

default(5)

func (*Column) SetLen

func (col *Column) SetLen(vals []string) (err error)

从参数中获取 Column 的 len1 和 len2 变量

len(len1,len2)

func (*Column) SetNullable

func (col *Column) SetNullable(vals []string) (err error)

nullable

type Models

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

Models 数据模型管理

func NewModels

func NewModels(db *sql.DB, d core.Dialect, tablePrefix string) (*Models, core.Engine, error)

NewModels 声明 Models 变量

返回对象中除了 Models 之外,还包含了一个 core.Engine 对象, 该对象的表名前缀由参数 tablePrefix 指定。

func (*Models) Close

func (ms *Models) Close() error

Close 清除所有的 core.Model 缓存

func (*Models) DB

func (ms *Models) DB() *sql.DB

func (*Models) Length

func (ms *Models) Length() (cnt int)

func (*Models) New

func (ms *Models) New(obj core.TableNamer) (*core.Model, error)

New 从一个 obj 声明 core.Model 实例

obj 可以是一个结构体或是指针。

func (*Models) NewEngine

func (ms *Models) NewEngine(e stdEngine, tablePrefix string) core.Engine

NewEngine 声明实现 core.Engine 接口的实例

func (*Models) Version

func (ms *Models) Version() string

Jump to

Keyboard shortcuts

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