go get -u github.com/go-ll/llorm
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{})