pastebin/internal/repositories/sqlite.go

31 lines
577 B
Go
Raw Normal View History

2023-09-30 13:47:59 +00:00
package repositories
import (
"gitter.top/drivers/sdbc"
"pastebin/config"
modelv1 "pastebin/model/v1"
"time"
)
var (
driver *sdbc.Driver
pastebinOperator sdbc.Operator
)
func GetPastebin() sdbc.Operator {
if driver == nil {
cfg := config.Get()
driver = sdbc.NewSDBC(&sdbc.Config{
Dbname: cfg.DBConfig.Dbname,
MaxIdleConn: 20,
MaxOpenConn: 200,
MaxLifetime: time.Hour,
Debug: cfg.DBConfig.Debug,
})
}
if pastebinOperator == nil {
pastebinOperator = driver.BindModel(&modelv1.ModelPastebin{})
}
return pastebinOperator
}