This commit is contained in:
lu.bai
2022-11-24 23:29:33 +08:00
parent 71d0135d6f
commit 48d5291b33
18 changed files with 445 additions and 191 deletions

View File

@@ -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() {