ThinkORM is a simple and Powerful ORM for Go.
go get github.com/thinkoner/torm
config := torm.Config{
Driver: "mysql",
Dsn: "root:abc-123@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=true",
}
db, _ := torm.Open(config)
type User struct {
Name string `torm:"column:name"`
Gender string `torm:"column:gender"`
Addr string
BirthDate string
Balance float64
CreatedAt time.Time
UpdatedAt time.Time
}
func (u *User) TableName() string {
return "users"
}
var users []User
db.Table("users").
Where("gender", "M").
Where("name", "like", "%a%").
WhereColumn("created_at", "!=", "updated_at").
WhereIn("addr", []interface{}{"Columbia", "Alaska"}).
WhereBetween("birth_date", []interface{}{"1990-01-01", "1999-12-31"}).
Get(&users)
This project is licensed under the Apache 2.0 license.
If you have any issues or feature requests, please contact us. PR is welcomed.