gorm table name automatically adds s at the end

Gorm table names automatically add s to the end. Whether it is gorm1 or gorm2, s will be added to the end of the table name you define when you operate the database.

gorm1 disables the table name plus s method

db.SingularTable(true)

gorm2 disables the table name plus s method

# NamingStrategy: schema.NamingStrategy{
    
    SingularTable: true}
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
    
    NamingStrategy: schema.NamingStrategy{
    
    SingularTable: true}})

Guess you like

Origin blog.csdn.net/weixin_42475906/article/details/131719787