korm

package module
v0.0.0-...-8a62f83 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

korm

Simple ORM For Go

quick start:

type Score struct {
	Id   uint64 `korm:"PRIMARY KEY"`
	Name string `korm:"not null"`
	Age  int8   `korm:"not null default 1"`
}

func main(){
	engine, _ := NewEngine("mysql", "root:123456@/User?charset=utf8")
	defer engine.Close()
	s := engine.NewSession().Model(&Score{})
	_ = s.DropTable()
	_ = s.CreateTable()
	_,_ = s.Insert(&Score{1, "tom", 3})
	score := &Score{}
	_ = s.First(score)
	
	scoreList := []Score{}
	_ = s.Find(&scoreList)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

与用户交互

func NewEngine

func NewEngine(driver, source string) (e *Engine, err error)

func (*Engine) Close

func (engine *Engine) Close()

func (*Engine) NewSession

func (engine *Engine) NewSession() *session.Session

func (*Engine) Transaction

func (engine *Engine) Transaction(f TxFunc) (result interface{}, err error)

type TxFunc

type TxFunc func(*session.Session) (interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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