mirror of https://github.com/rocboss/paopao-ce
parent
08b5d6d79d
commit
980c87ff8a
@ -1,30 +0,0 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package conf
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/rocboss/paopao-ce/pkg/naming"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
_sqlxdb *sqlx.DB
|
||||
_onceSqlx sync.Once
|
||||
)
|
||||
|
||||
func MustSqlxDB() *sqlx.DB {
|
||||
_onceSqlx.Do(func() {
|
||||
driver, db, err := newSqlDB()
|
||||
if err != nil {
|
||||
logrus.Fatalf("new sqlx db failed: %s", err)
|
||||
}
|
||||
_sqlxdb = sqlx.NewDb(db, driver)
|
||||
_sqlxdb.MapperFunc(naming.NewSnakeNamingStrategy().Naming)
|
||||
})
|
||||
return _sqlxdb
|
||||
}
|
Loading…
Reference in new issue