# README
Gorm'er —— GORM Manager
Installation
go get github.com/go-packagist/gormer/v2
Usage
package main
import (
"github.com/go-packagist/gormer/v2"
"gorm.io/gorm"
)
func main() {
m := gormer.NewManager(&gormer.Config{
Default: "db1",
Connections: map[string]gormer.Connection{
"db1": &gormer.MySQLConfig{
DSN: gormer.DSN{
Host: "127.0.0.1",
Port: 3306,
User: "root",
Pass: "123456",
DB: "test",
Options: map[string]string{
"charset": "utf8mb4",
"parseTime": "True",
},
}.String(),
GormConfig: &gorm.Config{
SkipDefaultTransaction: true,
},
},
"db2": &gormer.MySQLConfig{
DSN: gormer.DSN{
Host: "...",
}.String(),
},
},
}, gormer.WithInstance) // Instance mode
var user = struct {
Name string
}{}
m.Connect("db1").DB.First(&user)
gormer.Factory().Connect("db1").DB.First(&user) // use factory mode
gormer.Gormer().Connect("db2").DB.First(&user) // use instance mode
gormer.Connect("db1").DB.First(&user) // use instance mode
gormer.Connect().DB.First(&user) // use default connection
gormer.Connect().First(&user) // use default connection and ignore `DB`
println(gormer.Connect("db2").Err) // if db2 is err
}
License
The MIT License (MIT). Please see License File for more information.
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author