© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
4 replies
addamsson

Drizzle complains when I'm trying to insert into a table.

I have a schema that looks like this:
export const Organization = pGtable(
    "Organization",
    {
        id: text("id").primaryKey().notNull(),
        name: text("name").notNull(),
        createdAt: timestamp("createdAt", { precision: 3, mode: "string" })
            .defaultNow()
            .notNull(),
        updatedAt: timestamp("updatedAt", {
            precision: 3,
            mode: "string",
        }).notNull(),
    },
    (table) => {
        return {
            name_key: uniqueIndex("Organization_name_key").using(
                "btree",
                table.name,
            ),
        };
    },
);
export const Organization = pGtable(
    "Organization",
    {
        id: text("id").primaryKey().notNull(),
        name: text("name").notNull(),
        createdAt: timestamp("createdAt", { precision: 3, mode: "string" })
            .defaultNow()
            .notNull(),
        updatedAt: timestamp("updatedAt", {
            precision: 3,
            mode: "string",
        }).notNull(),
    },
    (table) => {
        return {
            name_key: uniqueIndex("Organization_name_key").using(
                "btree",
                table.name,
            ),
        };
    },
);

and when I'm trying to run a query against it:
import * as schema from "../src/drizzle/schema";
import { Client } from "pg";

export const client = new Client({
    connectionString: process.env.DATABASE_URL,
});

export const db = drizzle(client, { schema });

await db.insert(Organization).values({
    id: "68184833-8d03-41d6-95a2-4f23c4f097d6",
    name: "org",
    createdAt: new Date(),
    updatedAt: new Date(),
});
import * as schema from "../src/drizzle/schema";
import { Client } from "pg";

export const client = new Client({
    connectionString: process.env.DATABASE_URL,
});

export const db = drizzle(client, { schema });

await db.insert(Organization).values({
    id: "68184833-8d03-41d6-95a2-4f23c4f097d6",
    name: "org",
    createdAt: new Date(),
    updatedAt: new Date(),
});

typescript complains that my data is wrong:
Object literal may only specify known properties, and 'id' does not exist in type '{ id: string | SQL<unknown> | Placeholder<string, any>; ...
Object literal may only specify known properties, and 'id' does not exist in type '{ id: string | SQL<unknown> | Placeholder<string, any>; ...

if I add
as any
as any
at the end it works, but I'd rather not opt-out of type-safety. What am I doing wrong?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

drizzle asks for <table> `id` when doing insert
Drizzle TeamDTDrizzle Team / help
3y ago
How to insert data into table (seed) every time I do a 'drizzle-kit push'?
Drizzle TeamDTDrizzle Team / help
13mo ago
[HELP]: I'm trying to re-create a CTE-insert in drizzle, having some difficulties
Drizzle TeamDTDrizzle Team / help
3y ago
How do i insert a Enum value into a table
Drizzle TeamDTDrizzle Team / help
3y ago