Making Updateable<X> fields required

Excuse me if this has already been posted, but I recently turned on strict mode after completing my migration to TS and I'm struggling to make certain fields required when updating an entity. When I hover over UpdateableActivity it shows:
type UpdateableActivity = {
ID?: number | undefined;
name?: string | undefined;
year?: number | undefined;
isCurrent?: boolean | undefined;
venueID?: number | undefined;
moduleID?: number | undefined;
}
type UpdateableActivity = {
ID?: number | undefined;
name?: string | undefined;
year?: number | undefined;
isCurrent?: boolean | undefined;
venueID?: number | undefined;
moduleID?: number | undefined;
}
but hovering over Updateable shows:
type UpdateablePerson = Updateable<PersonTable>
// {
// id?: number,
// first_name?: string
// }
type UpdateablePerson = Updateable<PersonTable>
// {
// id?: number,
// first_name?: string
// }
if possible I'd like it to be something like:
type UpdateableActivity = {
ID?: number;
name: string;
year: number;
isCurrent: boolean;
venueID: number;
moduleID: number;
}
type UpdateableActivity = {
ID?: number;
name: string;
year: number;
isCurrent: boolean;
venueID: number;
moduleID: number;
}
https://kyse.link/MA3jQ is my playground link if that helps!
Solution:
You can't make them required by kysely. In SQL update statements, every column is optional. You can have your own interface that makes some fields required and use that as an input for your own update functions that use kysely....
Jump to solution
3 Replies
Solution
koskimas
koskimas3w ago
You can't make them required by kysely. In SQL update statements, every column is optional. You can have your own interface that makes some fields required and use that as an input for your own update functions that use kysely.
koskimas
koskimas3w ago
You can use a helper like this for example https://kyse.link/wvDvg
TheMelonAssassin
TheMelonAssassinOP3w ago
That makes sense. On the same subject, how come that for my own UpdateableActivity the fields have | undefined, but when hovering over Updateable there's no | undefined in the example
Want results from more Discord servers?
Add your server