mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
refactor
This commit is contained in:
@@ -15,17 +15,17 @@ type Dao struct {
|
||||
db *mongo.Database
|
||||
}
|
||||
|
||||
func NewDao() (r *Dao) {
|
||||
func NewDao() (r *Dao, err error) {
|
||||
r = new(Dao)
|
||||
clientOptions := options.Client().ApplyURI(config.CONF.Database.Url)
|
||||
client, err := mongo.Connect(context.TODO(), clientOptions)
|
||||
if err != nil {
|
||||
logger.LOG.Error("mongo connect error: %v", err)
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
r.client = client
|
||||
r.db = client.Database("game_hk4e")
|
||||
return r
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (d *Dao) CloseDao() {
|
||||
|
||||
Reference in New Issue
Block a user