Cannot Access Primary Key on Table

Hello, I am trying to access the primary key named id on the following table:
export const invites = mysqlTable(
"invites",
{
inviteeID: varchar("invitee_id", { length: 255 }).notNull(),
teamID: varchar("team_id", { length: 50 }).notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
status: mysqlEnum("status", ["pending", "accepted", "declined"]).notNull().default("pending"),
},
(table) => ({
id: primaryKey(table.inviteeID, table.teamID),
})
);
export const invites = mysqlTable(
"invites",
{
inviteeID: varchar("invitee_id", { length: 255 }).notNull(),
teamID: varchar("team_id", { length: 50 }).notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
status: mysqlEnum("status", ["pending", "accepted", "declined"]).notNull().default("pending"),
},
(table) => ({
id: primaryKey(table.inviteeID, table.teamID),
})
);
I am using the following command to try to update a row but I am getting an error and the id field does not show on the invite. Any idea why this might be? Thanks!
await db.update(invites).set({ status: "accepted" }).where(eq(invites.id, user.invites[0].id));
await db.update(invites).set({ status: "accepted" }).where(eq(invites.id, user.invites[0].id));
2 Replies
Liam
LiamOP17mo ago
The error:
Property 'id' does not exist on type 'MySqlTableWithColumns<{ name: "invites"; schema: undefined; columns: { inviteeID: MySqlVarChar<{ tableName: "invites"; enumValues: [string, ...string[]]; name: "invitee_id"; data: string; driverParam: string | number; hasDefault: false; notNull: true; }>; teamID: MySqlVarChar<...>; createdAt: MySqlTimestamp<...>; st...'.ts(2339)
Property 'id' does not exist on type 'MySqlTableWithColumns<{ name: "invites"; schema: undefined; columns: { inviteeID: MySqlVarChar<{ tableName: "invites"; enumValues: [string, ...string[]]; name: "invitee_id"; data: string; driverParam: string | number; hasDefault: false; notNull: true; }>; teamID: MySqlVarChar<...>; createdAt: MySqlTimestamp<...>; st...'.ts(2339)
iukea
iukea17mo ago
Can you post for your full schema here in a screenshot (it is a little squished And the query you are trying to do I will see if I can take a shot at it. Or it will blow up 🧑‍🔧🤪
Want results from more Discord servers?
Add your server