Answer the question
In order to leave comments, you need to log in
How to submit an SQL query with multiple JOINs in Prisma?
There is a request like this:
SELECT
bp.id AS bp_id,
streams.id AS stream_id
FROM business_profiles AS bp
INNER JOIN accounts AS acc on acc.business_profile_id = bp.id
INNER JOIN streams ON streams.stream_owner_id = acc.id
WHERE streams.id in (?);
model Account {
id BigInt @id @default(autoincrement())
business_profile BusinessProfile @relation(fields: [business_profile_id], references: [id])
business_profile_id BigInt
...
streams Stream[]
}
model Stream {
id BigInt @id @default(autoincrement())
stream_owner_id BigInt
account Account @relation(fields: [stream_owner_id], references: [id])
...
}
model BusinessProfile {
id BigInt @id @default(autoincrement())
...
accounts Account[]
}
const bpIDs = await this.client.businessProfile.findMany({
include: {
accounts: {
include: {
streams: true,
},
},
},
where: {
accounts: {
},
},
// select: {
// accounts: {
// select: {
// streams: {
// where: {
// id: {
// in: streamIDs,
// },
// },
// },
// },
// },
// },
});
console.log(bpIDs);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question