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);