Skip to content

go-cook/llorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llorm

Install

go get -u github.com/go-ll/llorm

Run

Start

e := NewEngine("sqlite3", "ll.db")
s := e.NewSession()

type User struct {
    Name string
    Age int64
}

var users []User

Insert

u1 := &User{Name: "Tom", Age: 18}
u2 := &User{Name: "Sam", Age: 25}
s.Insert(u1, u2, ...)

Find

s.Find(&users{})

Update

s.Where("Name = ?", "Tom").Update("Age", 30)

Delete

s.Where("Name = ?", "Tom").Delete()

Chain

s.Where("Age > 18").Limit(3).Find(&users)

Transaction

e.Transaction(func(s *session.Session) (result interface{}, err error) {
    _ = s.Model(&User{}).CreateTable()
    _, err = s.Insert(&User{"Tom", 18})
    return nil, errors.New("Error")
})

Migrate

e.Migrate(&User{})