Repository navigation
Add Config type open db
- support set cache expire time when query db
- add mysql and pgsql config type struct
- add ConnectMysql with ConnectPgSql method open db
mysql:
db, err := gormc.ConnectMysql(c.Mysql)
if err != nil {
log.Fatal(err)
}pgsql:
db, err := gormc.ConnectPgSql(c.PgSql)
if err != nil {
log.Fatal(err)
}notice:
- If you need the model type to support the DeletedAt field to automatically use gorm.DeletedAt and automatically determine whether to reference database, you can use the following modified version of goctl code_link, please download the corresponding package according to the system type.
#check version modified version has gormc flag
goctl -v
goctl version 1.4.3-gormc darwin/amd64- If you do not use gorm-zero support version, when the table contains optional fields, please manually import database/sql