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

Can we load the result to struct? #189

Closed
akhilravuri1 opened this issue Mar 15, 2022 · 2 comments
Closed

Can we load the result to struct? #189

akhilravuri1 opened this issue Mar 15, 2022 · 2 comments

Comments

@akhilravuri1
Copy link

Hi,

I am using golang 17 and nebula-go 2.5.1 versions

In other go-clients when we query data we can load that into a struct.

result, err := client.Execute(query)
result.Scan(&struct)

But here I can see the data is returned as string type.

	// Get a row from resultSet
	record, err := resultSet.GetRowValuesByIndex(0)
	if err != nil {
		log.Error(err.Error())
	}

	// Print whole row
	fmt.Println("The first row elements: \n", record.String())

If there is a way please document it or point me to that documentation link.

Thanks,
Akhil

@wey-gu
Copy link
Contributor

wey-gu commented Mar 23, 2022

Thanks Akhil and welcome to the nebula community :)
@Aiee , could you please help with Akhil?

@Aiee
Copy link
Contributor

Aiee commented Mar 23, 2022

Hello @akhilravuri1, you may update both the client and Nebula service to v2.6.0 or later to use the ExecuteJson() interface which returns the query result as a json string, and then you could use https://github.com/vesoft-inc/nebula-go/blob/master/json_example/parse_json_example.go as a reference to save the result in a self-defined struct.

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

3 participants