-
Notifications
You must be signed in to change notification settings - Fork 11
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
Edgedb json
value be mapped to json.RawMessage
go types instead of []byte
.
#315
Comments
Thanks for opening the issue! I'm not sure I understand what this is asking for though. package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/edgedb/edgedb-go"
)
func main() {
ctx := context.Background()
client, err := edgedb.CreateClient(ctx, edgedb.Options{})
if err != nil {
log.Fatal(err)
}
defer client.Close()
var result struct {
Thing json.RawMessage `edgedb:"thing"`
}
err = client.QuerySingle(ctx, `SELECT { thing := to_json('{"hello": "world"}') }`, &result)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(result.Thing))
} Maybe there are some scenarios where this doesn't work? Let us know. Thanks! |
if you put that query into an type ExampleResult struct {
Thing []byte `edgedb:"thing"`
} It would be better if it generated: type ExampleResult struct {
Thing json.RawMessage `edgedb:"thing"`
} json marshaling a json.RawMessage does the thing you would expect. json Marshaling []byte, marshals as list of numbers. and if |
Ok I see. That makes sense. It turns out that we can decode to If it happens that the only thing you want to do with your query results is json encode them, then you can use the |
No description provided.
The text was updated successfully, but these errors were encountered: