mgo_base.go 446 B

12345678910111213141516171819202122
  1. package models
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_index_lib/utils"
  5. "eta_gn/eta_index_lib/utils/mgodb"
  6. )
  7. func init() {
  8. if utils.MgoUrlData != `` {
  9. var mgoConfig mgodb.MgoConfig
  10. if e := json.Unmarshal([]byte(utils.MgoUrlData), &mgoConfig); e != nil {
  11. panic("mongodb链接失败,Err:" + e.Error())
  12. return
  13. }
  14. mgoCli := mgodb.MgoNewClient(mgoConfig)
  15. utils.MgoDataCli = mgoCli
  16. utils.MgoDataDbName = mgoConfig.Database
  17. }
  18. }