Is it possible to spread a relation object when using `with`?

I am using multiple table inheritance where I have a user table and two other separate tables for different user roles. When I do a query to find a user from the tables for the roles I would like to return the user tables columns spread on the object if that makes sense so if I do:
const userType1 = await db.query.userType1.findFirst({
where: eq(userType1.id, id),
with: {
user: true,
},
});
const userType1 = await db.query.userType1.findFirst({
where: eq(userType1.id, id),
with: {
user: true,
},
});
Right now userType1 has the type:
{
id: string,
...other userType1 info
user: {...}
}
{
id: string,
...other userType1 info
user: {...}
}
But I would like to have the user object spread inside the object instead. I can do this manually, but wanted to know if this was built in already or configurable.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server