1 Star 2 Fork 1

thinkgo / torm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
Jon Lee 提交于 2019-02-15 14:29 . Update README.md

ThinkORM

ThinkORM is a simple and Powerful ORM for Go.

Build Status Go Report Card Go Report Card GoDoc Join the chat Latest Stable Version License

Installation

go get github.com/thinkoner/torm

Quick start

Get the database connection:
config := torm.Config{
		Driver: "mysql",
		Dsn:    "root:abc-123@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=true",
	}
db, _ := torm.Open(config)
Query Builder:
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)

License

This project is licensed under the Apache 2.0 license.

Contact

If you have any issues or feature requests, please contact us. PR is welcomed.

1
https://gitee.com/thinkgo/torm.git
git@gitee.com:thinkgo/torm.git
thinkgo
torm
torm
master

搜索帮助