diegogub / aranGO

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

Cannot retrieve documents #5

Closed abijr closed 10 years ago

abijr commented 10 years ago

I'm able to save new documents and patch them, but I'm not being able to retrieve the documents. If I do this:

var user User
dbase, _ := aranGO.Connect("http://localhost:8529", "", "", false)
b := dbase.DB("kails").Col("users")
b.Any(user)

log.Println(user)

It just prints an empty User (default values). And I do have documents in the collection. Do I need to add credentials for the database?

Apparently, Any requires to send the collection name on the payload and aranGO isn't sending it. I might start a pull request with a fix for this (First, Example are also affected).

abijr commented 10 years ago

I enabled logging and confirmed this:

session.go:175: 
{
    "Connection": [
        "Keep-Alive"
    ],
    "Content-Length": [
        "114"
    ],
    "Content-Type": [
        "application/json; charset=utf-8"
    ],
    "Server": [
        "ArangoDB"
    ]
}
2014/09/21 18:30:32 Body:
session.go:180: 
{
    "error": true,
    "code": 400,
    "errorNum": 600,
    "errorMessage": "[ArangoError 600: expecting a valid JSON object as body]"
}
diegogub commented 10 years ago

hello @abijr , thanks for your report. I will take a look now at this issue.

diegogub commented 10 years ago

@abijr I think I fixed Any query, and tested Example query, and Example is working. I added a simple_test.go file to start adding testing code. So, If you wish you could add new simple query test and others. Thanks for your help!

abijr commented 10 years ago

That was quick! thanks @diegogub! I'll check it and report on it later.

diegogub commented 10 years ago

@abijr you are welcome! Are you using aranGO in any project?. If so, I added some cool features as AqlBuilder and Models that could help a lot. I've been quite busy but I need to add some nice documentation. Any doubt you can write to me.

abijr commented 10 years ago

It's medium sized school project, and I'm just checking out different databases. I'll probably stick with arango because it has the graph stuff. If I do stick to this i'll be able to help you out with documentation if you want. Add a TODO somewhere (so we don't end up doing the same stuff).

abijr commented 10 years ago

@diegogub I've done some testing and the Any and First methods still aren't working (wanted to really confirm it first). I'm going to send a pull request with more tests for this soon.

diegogub commented 10 years ago

Hello @abijr, I check this now. Enabling verbose, I see that both request, First and Any are done correctly. Let me see, thanks!

diegogub commented 10 years ago

@abijr, I see the error. It's an error with the json arangodb response. Instead of responding just the document in Any Query It returns: { "document": { "_id": "testCol/943649553868", "_rev": "943649553868", "_key": "943649553868", "Text": "test string" }, "error": false, "code": 200 }

I don't really know why they use document- I will fix this now, sorry

diegogub commented 10 years ago

hello @abijr , now all test are passing. It's all merged to dev , close this issue please if you see it fixed. Thanks @abijr

abijr commented 10 years ago

I've confirmed this is working as intended.