Error updating a record

I'm getting an error typescript: Cannot find name 'buildings'. Did you mean 'buildingId'? [2552] when trying to update an item
import * as schema from "@/drizzle/schema"
import { PostgresJsDatabase, drizzle } from "drizzle-orm/postgres-js"
import postgres from "postgres"

const queryClient = postgres(process.env.DATABASE_URL ?? "", { max: 3 })
const db = drizzle(queryClient, { schema })

const updatedBuilding: { updatedBuildingId: number }[] = await db
.update(buildings)
.set({
buildingName,
buildingLocation,
country,
buildingComments,
})
.where(eq(buildings.buildingId, buildingId))
.returning({ updatedBuildingId: buildings.buildingId })
import * as schema from "@/drizzle/schema"
import { PostgresJsDatabase, drizzle } from "drizzle-orm/postgres-js"
import postgres from "postgres"

const queryClient = postgres(process.env.DATABASE_URL ?? "", { max: 3 })
const db = drizzle(queryClient, { schema })

const updatedBuilding: { updatedBuildingId: number }[] = await db
.update(buildings)
.set({
buildingName,
buildingLocation,
country,
buildingComments,
})
.where(eq(buildings.buildingId, buildingId))
.returning({ updatedBuildingId: buildings.buildingId })
I'm using nextjs13 app directory and this code is in a form action What could be the issue
3 Replies
NinjaBunny
NinjaBunny•2y ago
if the typescript error is referring to the line where you're trying to do .update(buildings) could it be that you are not importing your buildings table
hobby_codes
hobby_codesOP•2y ago
No I'm not..but I imported * as schema from "@drizzle/schema" Importing buildings instead worked...thank you so much
NinjaBunny
NinjaBunny•2y ago
no problem happy to help 🙂
Want results from more Discord servers?
Add your server