golang-gosqlgolang orm 庫(kù)
gosql 是一款 golang style 語(yǔ)法的 golang orm 庫(kù)。
- 優(yōu)雅的語(yǔ)法,支持批量插入;
- 輕松嵌套條件,處理各種復(fù)雜的查詢 sql,諸如:and 和 or 組合;
- 全語(yǔ)法支持:for update 鎖、is null、exists 子查詢等基本上所有 sql 語(yǔ)法
特xing
- Golang-style SQL builder go語(yǔ)言風(fēng)格sql生成
- Unlimited nesting query 查詢條件無限嵌套
- Reading and Writing Separation 讀寫分離
- Delay connection creation 延遲創(chuàng)建連接
- ORM maping to sturct ORM映射結(jié)構(gòu)體
- Transactions 事務(wù)支持
- Versatile 功能多樣的
- Clean Code 簡(jiǎn)潔的代碼
- Bulk Insert 支持批量插入
風(fēng)格如下
user := &UserModel{}
err := db.Fetch(user,
gosql.Columns("id","name"),
gosql.Where("id", 1),
gosql.Where("[like]name", "j%")
gosql.OrWhere(func(s *Clause) {
s.Where("[>=]score", "90")
s.Where("[<=]age", "100")
}),
GroupBy("type"),
OrderBy("score DESC"),
)
評(píng)論
圖片
表情
