gorm use custom tablename
type User struct{ Id int Name string } // 自定义表名 fu… 继续阅读 gorm use custom tablename
type User struct{ Id int Name string } // 自定义表名 fu… 继续阅读 gorm use custom tablename
import ( "database/sql" "encoding/j… 继续阅读 golang gorm use oracle
执行自定义sql func increaseAmapAdcodeCityCode(adcode st… 继续阅读 golang gorm exec sql
gorm批量更新 global.DB.Model(&BilibiliUpStatus{}).… 继续阅读 golang gorm batch updates
type User struct { Name string `gorm:"index:i… 继续阅读 gorm 联合索引
type BaiduHotContent struct { gorm.Model Hot strin… 继续阅读 panic: invalid sql type (slice) for mysql
func IsNewHot(hot string) bool { var Record BaiduH… 继续阅读 判断gorm查询结果数据是否存在
type LogPassword struct { gorm.Model PassWord stri… 继续阅读 gorm创建text字段
dsn := “user:pass@tcp(127.0.0.1:3306)/dbname?chars… 继续阅读 GORM 使用 database/sql 维护连接池
//db, err = gorm.Open(“mysql”, “root:password@tcp(… 继续阅读 gorm使用连接池
package util import ( “gorm.io/driver/sqlite” “gor… 继续阅读 gorm 使用内存中的SQLite
db.Create(&user) // 将 `CreatedAt` 设为当前时间 // 想要… 继续阅读 gorm自定义CreatedAt值
type Student struct { Age int64 `gorm:”column:his_… 继续阅读 gorm自定字段名
type Blog struct { ID int Author Author `gorm:”emb… 继续阅读 gorm字段使用自定义前缀
newUser := model.User{ Phone: phone, Password: str… 继续阅读 gorm insert捕获失败情况
//默认0表示不限制 db.DB().SetMaxIdleConns(2000) db.DB().S… 继续阅读 gorm设置最大连接数和最大闲置数
db.Set(“grom:table_options”, “ENGINE=InnoDB”)
// 如果设置为true,`User`的默认表名为`user`,使用`TableName`设置的表名… 继续阅读 gorm全局禁用表名复数
db.LogMode(true)
gorm.DefaultTableNameHanlder = func(db *gorm.DB,de… 继续阅读 gorm给默认表名加前缀和后缀