Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct way to get multiple documents ? #70

Closed
stefanwuthrich opened this issue Dec 11, 2017 · 1 comment
Closed

correct way to get multiple documents ? #70

stefanwuthrich opened this issue Dec 11, 2017 · 1 comment

Comments

@stefanwuthrich
Copy link

I try to do something like this:

`
query := "FOR d IN scenario RETURN d"
cursor, err := storage.ArangoDb.Query(storage.Ctx, query, nil)

if err != nil {
	fmt.Println(err)
}

var scenarios []Scenario
_, err = cursor.ReadDocument(storage.Ctx, &scenarios)

`

which of course gives following error:
cannot unmarshal object into Go value of type []model.Scenario
as cursor.ReadDocument get's only 1 document.

What is the correct way to get full array?

@ewoutp
Copy link
Contributor

ewoutp commented Dec 11, 2017

@stefanwuthrich You should iterate over the cursor for every document.
See https://github.com/arangodb/go-driver#querying-documents-one-document-at-a-time

Note. This driver will internally fetch multiple documents at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants