DT
Drizzle Teamβ€’3mo ago
Meexa

Providing optional columns to insert query results in type error

I have this table
export const team = pgTable(
'Team',
{
id: bigint('id', { mode: 'number' }).primaryKey().generatedByDefaultAsIdentity(),
creatorId: uuid('creator_id'),
createdAt: timestamp('created_at')
.defaultNow()
.notNull(),
updatedAt: timestamp('updated_at')
.defaultNow()
.notNull(),
deletedAt: timestamp('deleted_at'),
},
);
export const team = pgTable(
'Team',
{
id: bigint('id', { mode: 'number' }).primaryKey().generatedByDefaultAsIdentity(),
creatorId: uuid('creator_id'),
createdAt: timestamp('created_at')
.defaultNow()
.notNull(),
updatedAt: timestamp('updated_at')
.defaultNow()
.notNull(),
deletedAt: timestamp('deleted_at'),
},
);
- creatorId isn't anywhere in the auto complete - Adding creatorId in the values object results in a type error. Is this normal behavior? Am I not understanding something? πŸ€”
No description
No description
8 Replies
Meexa
MeexaOPβ€’3mo ago
It does work though, it's only typescript that doesn't like it Sorry for bumping. Do I need to provide more context for this problem? What would help?
Darren
Darrenβ€’3mo ago
i would first question what youre importing ah also... youre table has capital letter in it... that maybe the issue
Meexa
MeexaOPβ€’3mo ago
I renamed the variable to teamTable to make sure it's the table from the schema and removed the capital T from the table name. Still doesn't allow me to pass creatorId
export const teamTable = pgTable(
'team',
{
id: bigint('id', { mode: 'number' }).primaryKey().generatedByDefaultAsIdentity(),
creatorId: uuid('creator_id'),
createdAt: timestamp('created_at')
.defaultNow()
.notNull(),
updatedAt: timestamp('updated_at')
.defaultNow()
.notNull(),
deletedAt: timestamp('deleted_at'),
},
);
export const teamTable = pgTable(
'team',
{
id: bigint('id', { mode: 'number' }).primaryKey().generatedByDefaultAsIdentity(),
creatorId: uuid('creator_id'),
createdAt: timestamp('created_at')
.defaultNow()
.notNull(),
updatedAt: timestamp('updated_at')
.defaultNow()
.notNull(),
deletedAt: timestamp('deleted_at'),
},
);
Meexa
MeexaOPβ€’3mo ago
No description
Meexa
MeexaOPβ€’3mo ago
The type is there πŸ€”
No description
Meexa
MeexaOPβ€’3mo ago
No description
Darren
Darrenβ€’3mo ago
ok whats in your tsconfig.json file is strict: true?
Meexa
MeexaOPβ€’3mo ago
That might be it actually πŸ˜… can’t try until tomorrow but this project was setup from scratch instead of my regular nextjs setup, so the tsconfig might be missing some things Yep that was it, thanks @Darren πŸ™Œ
Want results from more Discord servers?
Add your server