Zack
Zack
Explore posts from servers
DTDrizzle Team
Created by Zack on 1/12/2024 in #help
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.
1 replies
DTDrizzle Team
Created by Zack on 12/28/2023 in #help
Recommended place to add prepared statements
Where is the recommended place to define prepared statements? Does it make the most sense to define them in the schema file or at the service layer? Just generally I guess where is the best place to declare prepared statements? I was also just curious on the general threshold of query complexity to make creating a prepared statement worthwhile. How complex does a repeated query have to be in order to see a performance benefit from a prepared statement?
2 replies