To get this result, you would have to explicitly state to not be interested in any of the middle table columns like this:
const myARowsWithB = db.query.A.findMany({
with: {
aToB: {
columns: false, // Or even columns: {}
with: {
b: true,
}
},
}
})
// Now you can do this
myARowsWithB[0].b.map(...)
This behaviour could be extended not only to a N:N relation but in general to any chain of relations when you are only interested in the very last JOINed table like this:
const myARowsWithD = await db.query.A.findMany({
with: {
aToB: {
columns: false,
with: {
b: {
columns: false,
with: {
c: {
columns: false,
with: {
d: true,
},
},
},
},
}
},
}
})
// Now you can do this
myARowsWithD[0].d.map(...)
Describe what you want
Let's say we have a
N:N
relation between tablesA
andB
through theA_to_B
table.When I query
A
and want all theB
without any column fromA_to_B
, what I get is thisInstead it would be better in my opinion to have a result that looks something like this:
To get this result, you would have to explicitly state to not be interested in any of the middle table columns like this:
This behaviour could be extended not only to a
N:N
relation but in general to any chain of relations when you are only interested in the very lastJOIN
ed table like this: