首页 > 解决方案 > gorm v2:如何处理 v1 中的 gorm.Scope?

问题描述

我正在将 GORM 迁移到 v2。在这个版本的 GORM 中删除了gorm.Scope 。我需要 TableName()、FieldByName() 等。有相同功能的替代品吗?

标签: go-gorm

解决方案


金珠回答:

https://gorm.io/docs/write_plugins.html

db.Statement.Schema.LookUpField("Name")
db.Statement.Table

推荐阅读