ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## orm orm包含各种api的操作 ## 预览 ```go package main import ( "fmt" "github.com/gohouse/gorose/v2" _ "github.com/mattn/go-sqlite3" ) type Users struct { Uid int64 `gorose:"uid"` Name string `gorose:"name"` Age int64 `gorose:"age"` } func (u *Users) TableName() string { return "users" } var err error var engin *gorose.Engin func init() { engin, err = gorose.Open(&gorose.Config{Driver: "sqlite3", Dsn: "./db.sqlite"}) } func DB() gorose.IOrm { return engin.NewOrm() } func main() { db := DB() var u []Users var count int64 count,err = db.Table(&u).Fields("uid").AddFields("name,age"). Where("age",">",0).OrderBy("uid desc").GroupBy("age"). Having("age>15").Limit(10).Offset(1).Count() db.Select() fmt.Println(count,err,u) } ``` --- 温馨提示, 不要忘了导入对应的驱动, 如 MySQL驱动: ```go import _ "github.com/go-sql-driver/mysql" ```