vivek
vivek
DTDrizzle Team
Created by vivek on 2/15/2024 in #help
Property 'lists' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing
im getting an error tryna do a findfirst on a table from db error says Property 'lists' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?" here's the code import { tasks, type TaskType } from "@db/schema"; import { db } from "../../../db/sql"; import { auth } from "@lib/auth"; import { createTaskRequestValidator, updateTaskRequestValidator, } from "@lib/types"; import { and, eq } from "drizzle-orm"; import { v4 } from "uuid"; import { ZodError } from "zod"; async function POST(request: Request) { const session = await auth(); if (!session) return new Response("Unauthorized", { status: 401 }); try { const task = createTaskRequestValidator.parse(await request.json()); const listExists = await db.query.lists.findFirst({ where: (list, { and, eq }) => and(eq(list.id, task.listId), eq(list.userId, session.user.id)), }); heres the schema of lists export const lists = pgTable("lists", { id: text("id").primaryKey().notNull(), userId: text("user_id").notNull(), createdAt: timestamp("created_at").notNull().defaultNow(), updatedAt: timestamp("updated_at").notNull().defaultNow(), name: text("name").notNull(), }); heres the code from my db import { Pool } from "pg"; import { drizzle } from "drizzle-orm/node-postgres"; import { migrate } from "drizzle-orm/node-postgres/migrator"; import "dotenv/config"; const pool = new Pool({ connectionString: process.env.DATABASE_URL, }); export const db = drizzle(pool); async function main() { console.log("migration started..."); await migrate(db, { migrationsFolder: "drizzle" }); console.log("migration ended..."); process.exit(0); } main().catch((err) => { console.log(err); process.exit(0); });
2 replies