Barrabasz
Barrabasz
DTDrizzle Team
Created by Barrabasz on 12/28/2023 in #help
How do I type the `with` object part of a query builder if I extract it to it's own object?
I have a large with object that I reuse across multiple queries and I wanted to extract it to its own variable for reusing it. I typed this object with DBQueryConfig["with"] which seems to make typescript happy but the return type is not inferred correctly. Am I missing something?
const fullEventWithParams: DBQueryConfig["with"] = {
users: {
with: {
// this is a many-to-many table
// and this object is not getting inferred
user: {
columns: {
id: true,
email: true,
firstName: true,
lastName: true,
phone: true,
},
},
},
},
owner: { columns: { password: false } },
vehicleType: { columns: { id: true, name: true } },
location: true,
examination: true,
};

const events = await db.query.events.findMany({
with: fullEventWithParams,
});
const fullEventWithParams: DBQueryConfig["with"] = {
users: {
with: {
// this is a many-to-many table
// and this object is not getting inferred
user: {
columns: {
id: true,
email: true,
firstName: true,
lastName: true,
phone: true,
},
},
},
},
owner: { columns: { password: false } },
vehicleType: { columns: { id: true, name: true } },
location: true,
examination: true,
};

const events = await db.query.events.findMany({
with: fullEventWithParams,
});
6 replies
DTDrizzle Team
Created by Barrabasz on 12/27/2023 in #help
Can't set nullable field back to null in drizzle-studio
drizzle-studio does not allow me to set an int column to null even when choosing NULL from the dropdown. It defaults to a 0 which then throws an error upon saving.
2 replies