Unsafe argument of type `any` inside select where eq query

I am getting the following type error even though I am not passing parameters of type any. Correct me if I am wrong because I am a typescript begineer. Refer to the screenshots attached.
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
import { timeTable } from "~/drizzle/out/schema";

export const timeTableRouter = createTRPCRouter({
getAll: protectedProcedure.query(async ({ ctx }) => {
const timeTables = await ctx.db
.select()
.from(timeTable)
.where(eq(timeTable.userId, ctx.session.user.id));
}),
});
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
import { timeTable } from "~/drizzle/out/schema";

export const timeTableRouter = createTRPCRouter({
getAll: protectedProcedure.query(async ({ ctx }) => {
const timeTables = await ctx.db
.select()
.from(timeTable)
.where(eq(timeTable.userId, ctx.session.user.id));
}),
});
timeTable schema (autogenerated from introspect) I have not looked up the doc for writing schema as I only wanted to use drizzle for querying data from my exisiting database on planetscale
...
export const timeTable = mysqlTable("TimeTable", {
id: varchar("id", { length: 191 }).primaryKey().notNull(),
subjectId: varchar("subjectId", { length: 191 }).notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
isLab: tinyint("isLab").default(0).notNull(),
dayName: mysqlEnum("dayName", ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']).notNull(),
endTime: time("endTime").notNull(),
startTime: time("startTime").notNull(),
timetableName: varchar("timetableName", { length: 191 }).notNull(),
},
(table) => {
return {
subjectIdDayNameStartTimeEndTimeKey: uniqueIndex("TimeTable_subjectId_dayName_startTime_endTime_key").on(table.subjectId, table.dayName, table.startTime, table.endTime),
subjectIdIdx: index("TimeTable_subjectId_idx").on(table.subjectId),
userIdIdx: index("TimeTable_userId_idx").on(table.userId),
}
});
...
...
export const timeTable = mysqlTable("TimeTable", {
id: varchar("id", { length: 191 }).primaryKey().notNull(),
subjectId: varchar("subjectId", { length: 191 }).notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
isLab: tinyint("isLab").default(0).notNull(),
dayName: mysqlEnum("dayName", ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']).notNull(),
endTime: time("endTime").notNull(),
startTime: time("startTime").notNull(),
timetableName: varchar("timetableName", { length: 191 }).notNull(),
},
(table) => {
return {
subjectIdDayNameStartTimeEndTimeKey: uniqueIndex("TimeTable_subjectId_dayName_startTime_endTime_key").on(table.subjectId, table.dayName, table.startTime, table.endTime),
subjectIdIdx: index("TimeTable_subjectId_idx").on(table.subjectId),
userIdIdx: index("TimeTable_userId_idx").on(table.userId),
}
});
...
2 Replies
Maston
Maston•2y ago
import {eq} from 'drizzle-orm'
Blucin
BlucinOP•2y ago
thank you, so stupid of me to ignore that from the docs 😅 also the error straight up said that
Want results from more Discord servers?
Add your server