diegogub / aranGO

Golang driver for ArangoDB
Apache License 2.0
125 stars 31 forks source link

AvailableDBs() always outputs [] #17

Closed kkdd closed 9 years ago

kkdd commented 9 years ago

AvailableDBs() always outputs [].

s, err := aranGO.Connect("http://localhost:8529", "root", "", false)
dbs, err := s.AvailableDBs()
fmt.Println(dbs)
diegogub commented 9 years ago

Thanks, I will check it now. Which version of ArangoDb are you using?

kkdd commented 9 years ago

I'm using ArangoDB 2.6.0.

kgcrom commented 9 years ago

I find modify two case. 1.

//session.go (Line: 108)
switch res.Status() {
  case 200:
    return s.dbs.List, nil 
  case 400:
    return nil, errors.New("request is invalid")
  default:
    return s.dbs.List, nil 
  }

2.

//database.go (remove comment DatabaseResult struct) and then
//session.go
  res.Unmarshal(&dbResult)

  switch res.Status() {
  case 200:
    return dbResult.Result, nil 
  case 400:
    return nil, errors.New("request is invalid")
  default:
    return dbResult.Result, nil 
  }

I can't imagine what you want. Have a good day :smiley:

kkdd commented 9 years ago

The following code seems to work well:

func DbExist(host, db string) bool {
    var s napping.Session
    var dbs aranGO.Databases
    s.Get(host + "/_api/database/user", nil, &dbs, nil)
    for _, x := range dbs.List {  // dbs.List = AvailableDBs()
        if x == db {
            return true
        }
    }
    return false
}
diegogub commented 9 years ago

Hello @kkdd , I did hotfix for this. sorry for the delay! thanks!