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

Added ability to handle multiple queries #159

Merged
merged 1 commit into from
Oct 17, 2024
Merged

Conversation

remade
Copy link
Collaborator

@remade remade commented Oct 15, 2024

Added the ability to utilise SurrealDB multi-query capabilities. The raw results are returned and the user can directly unmarshal the result

Example:

queries := []surrealdb.QueryStmt{
    {SQL: "CREATE person SET name = 'John'"},
    {SQL: "SELECT * FROM type::table($tb)", Vars: map[string]interface{}{"tb": "person"}},
}

err := surrealdb.QueryRaw(s.db, &queries)
if err != nil {
    panic(err)
}

var created []testPerson
err = queries[0].GetResult(&created)
if err != nil {
    panic(err)
}

var selected []testPerson
err = queries[1].GetResult(&selected)
if err != nil {
    panic(err)
}

// fmt.Printf("%+v\n", created)
// fmt.Printf("%+v\n", selected)

@remade remade requested a review from tobiemh October 15, 2024 08:45
@remade remade merged commit 08ad39f into main Oct 17, 2024
2 checks passed
@remade remade deleted the query-raw-unmarshalling branch October 17, 2024 14:49
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

Successfully merging this pull request may close these issues.

1 participant