Gorm Updating a record and getting the updated version back

QuestionI am trying to update a record in the database using the document's ID to identify it. If the update is successf...

Gorm Preload don't works with spec ID in Model()

type Message struct { gorm.Model Attachment Attachment}type Attachment struct { gorm.Model MessageID uint}N...

Gorm The mysql bit(1) data type to Golang bool data type is supported

Describe the featureThe mysql bit(1) data type to Golang bool data type is supported希望 gorm 可以支持 mysql 的bit(1) 数据类型转为 go...

Gorm Can not create reverse foreign key field for custom field

GORM Playground Linknogorm versiongorm.io/driver/sqlite v1.5.3gorm.io/gorm v1.25.4DescriptionWhen using has many Foreign...

Gorm How to refresh connection password

Your issue may already be reported! Please search on the issue track before creating one.What version of Go are you usin...

Gorm Mysql 数据库模型中设置bool 类型对应tinyint(1)时,添加默认值后,插入数据只会设置默认值

使用的gorm版本为v1.24.6模型定义如下:type User struct { BaseModel Account string `json:"account" gorm:"type:v...

Gorm 请问gorm的Rows方法对连接数有什么影响?

背景:业务中需要以事务的方式同时更新多条记录,代码逻辑如下: tx := Db.Begin() rows, err := tx.Table(...).Where(...).Rows() if err != nil ...

Gorm exec执行原生SQL时,占位符不起作用

请问为什么我执行以下语句会报错?err := a.MysqlDB.db.Exec("CREATE USER ? IDENTIFIED BY ?", a.Name, a.Pwd).Error报错信息为[1.918ms] [rows:0] CR...

Gorm 希望增加一个类型 Scope

Describe the feature目前写scope函数是这样的func WhereId(id uint) func(tx *gorm.DB) *gorm.DB{// TODO }这样太麻烦了 每次要写很长的一串 func(tx *go...

Gorm how to update one more column when I use the soft-delete method

Your QuestionUseing the soft delete, gorm can only update one column like deleted_at or flag.But now, I alse need to upd...

Gorm 🚀 Feature Request: Hide relations and fields to not expose private and sensitive data

Describe the featureAbility to hide fields and relations at runtimeMotivationI want to expose an array of users as an en...

Gorm unsupported Scan to map

GORM Playground Linkhttps://github.com/go-gorm/playground/pull/654reproducefunc TestDbErr(t *testing.T) { type config...

Gorm sqlite test (1.19 in ubuntu:latest) : table xxx has more than one primary key

GORM PR Linkhttps://github.com/go-gorm/gorm/pull/6627Descriptioni want to make PR to add some config for migrator, it ha...

Gorm 使用gorm.Model创建表时出现主键错误

我的环境go 1.18gorm.io/driver/sqlite v1.5.4gorm.io/gorm v1.25.4我的代码var db *gorm.DBtype Assets struct { gorm.Model}func in...

Gorm gorm支持临时表查询么?应该如何使用?

Your Questiongorm支持临时表查询么?应该如何使用?The document you expected this should be explained比如我有这段SQL语句,我想在gorm里面使用,应该如何做?-- 创建一个...

Gorm Disable auto updated_at globally

Your QuestionMy business entity already has a updated_at that I perform business logic on, I want to disable gorm's auto...

Gorm How to only select the child table depending on its grandparent table's key (this key only exists in its direct Parent table)

I have 3 tables in this image.A table "user" can have many "catalog_habit", and the "catalog_habit" can have many "habit...

Gorm Save方法更新数据

Your Question使用Save方法更新数据,如果updateTx.RowsAffected == 0 就会走Create新增一条数据!The document you expected this should be explaine...

Gorm Preload and Scan into a struct?

I created 2 model: User and Order. Assuming a one-to-many relationship between User and Order like the following:type Us...

Gorm When migrating MySQL database tables, if the new table adds a primary key, the migration will fail

GORM Playground Linkhttps://github.com/go-gorm/playground/pull/1Descriptionold table:CREATE TABLE `workspace_binding` ( ...
上一页 下一页
.