Custom `Select` object returns type `any`

Rrykuno5/13/2023
Databases like Planetscale do not support FK constraints. As I understand I can manipulate the returned data structure from within the select clause. The data structure returned is correct but there is a typescript error casting it to any. Is there a way to fix this or am I misusing select?
const [event] = await db
.select({
...events,
createdBy: {
...users
}
})
.from(events)
.innerJoin(users, eq(events.createdByUserId, users.id))
.where(eq(events.id, params.id));
const [event] = await db
.select({
...events,
createdBy: {
...users
}
})
.from(events)
.innerJoin(users, eq(events.createdByUserId, users.id))
.where(eq(events.id, params.id));
export const events = mysqlTable("events", {
id: cuid2("id").primaryKey().notNull(),
name: text("name").notNull(),
description: text("description"),
image: text("image").notNull(),
privacy: text("privacy", { enum: ["public", "private"] }).notNull(),
startDate: timestamp("startDate").notNull(),
endDate: timestamp("endDate").notNull(),
createdByUserId: cuid2("created_by_user_id").notNull(),
created_at: timestamp("created_at").notNull().defaultNow(),
updated_at: timestamp("updated_at").notNull().defaultNow().onUpdateNow()
});
export const events = mysqlTable("events", {
id: cuid2("id").primaryKey().notNull(),
name: text("name").notNull(),
description: text("description"),
image: text("image").notNull(),
privacy: text("privacy", { enum: ["public", "private"] }).notNull(),
startDate: timestamp("startDate").notNull(),
endDate: timestamp("endDate").notNull(),
createdByUserId: cuid2("created_by_user_id").notNull(),
created_at: timestamp("created_at").notNull().defaultNow(),
updated_at: timestamp("updated_at").notNull().defaultNow().onUpdateNow()
});

Looking for more? Join the community!