© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
23 replies
wailroth

Schema to type

Hey guys, how do you make a schema item as a static type ?

for example, this thing:
export const orderItems = pgTable("orderItem", {
        product_id: serial("product_id").notNull(),
        order_id: serial("order_id").notNull(),
        quantity: integer("quantity")

    },
    (orderItems) => ({
            compoundKey: primaryKey(orderItems.product_id, orderItems.order_id),
        }
    ))
export const orderItems = pgTable("orderItem", {
        product_id: serial("product_id").notNull(),
        order_id: serial("order_id").notNull(),
        quantity: integer("quantity")

    },
    (orderItems) => ({
            compoundKey: primaryKey(orderItems.product_id, orderItems.order_id),
        }
    ))

as

{
productId: number,
order_id: number,
quantity: number
}
{
productId: number,
order_id: number,
quantity: number
}
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

how to generate type from schema
Drizzle TeamDTDrizzle Team / help
2y ago
Smarter way to get schema type
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle schema type error
Drizzle TeamDTDrizzle Team / help
2y ago
Ensure Drizzle findMany conforms to Typebox schema
Drizzle TeamDTDrizzle Team / help
3y ago