Hi all - playing around with the golang client. I'...
# orm-help
l
Hi all - playing around with the golang client. I'm trying to grab a list of users with a few related records. A user has many databases. I've queried them with
db.User.Database.Some()
A user has many alerts. I've queried them with
db.User.Alert.Some()
An alert has one notification. I've tried querying it with
db.Alert.Notification.Some()
, but
Some
isn't available here. If it's a "has one" relationship, should I be using another function instead?
Copy code
users, err := prisma.User.FindMany(
		db.User.Alert.Some(
			db.Alert.Notification.Some(),
		),
		db.User.Database.Some(),
	).Exec(ctx)
m
cc @Luca
l
For ‘has one’ it should be called
Where
instead of
Some
l
ok - so this should work?
Copy code
users, err := prisma.User.FindMany(
		db.User.Alert.Some(
			db.Alert.Notification.Where(),
		),
		db.User.Database.Some(),
	).Exec(ctx)
l
yep
l
ok that appears to typecheck. Thanks!
followup question - does
.Some()
and
.Where()
execute an inner join? Or are these models stitched together under the hood with multiple sql queries?
l
I’m not sure if I understand. This will result in one database call, i.e. one big query, but the query itself may contain many subqueries (a sub SELECT etc.) or many joins
l
ok that makes sense. I guess I'm curious whether this query would omit users without databases, or users with alerts without notifications? With
.Some()
and
.Where()
, is it required that all relations have records?
l
Well it will query for whatever you specify in the Some(), if you leave it empty I believe it should return users which have at least one database or have an alert->notification