edgedb-go
edgedb-go copied to clipboard
Query pass slice
I have yet to find a way to pass a slice of edgedb.UUIDs to *edgedb.Client.Query.
err = db.QuerySingle(ctx, `
INSERT Restaurant {
owner := <User>(Select User filter .id = <uuid>$0),
managers := <User>(Select User filter .id = <uuid>$1),
name := <str>$2,
description := <str>$3
}
`, &c, randomUser(db, insertedUsers).ID,
randomUserIDs(db, insertedUsers, 3),
gofakeit.Company(),
gofakeit.Adverb())
Am I reading this correctly? It looks like you want to pas several User
ids to $1
to select multiple managers? Passing sets as arguments is not supported so you need to change the query to make <uuid>$1
an array. I think something like this will work for the managers sub query.
select User filter contains(<array<uuid>>$1, .id)
This might be an alternative spelling.
select User filter .id in array_unpack(<array<uuid>>$1)
Thank you maybe there is a way to include that in the docs? I believe it might be helpful for new users.
I'll have a look at adding it.
added this to the docs in https://github.com/edgedb/edgedb-go/commit/7315ffdbf20cbff04b02f9a19db845e8cd42a4fe