How to generate type for individual items?

I have a schema.ts here:
import { sql } from 'drizzle-orm';
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';

export const comments = sqliteTable('comments', {
url: text('url'),
authorId: text('author_id').notNull(),
upvotes: integer('upvotes').notNull().default(0),
downvotes: integer('downvotes').notNull().default(0),
parentId: text('parent_id'), // For replies, null if it's a top-level comment
timestamp: text('timestamp')
.notNull()
.default(sql`CURRENT_TIMESTAMP`)
});

export const users = sqliteTable('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique()
});
import { sql } from 'drizzle-orm';
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';

export const comments = sqliteTable('comments', {
url: text('url'),
authorId: text('author_id').notNull(),
upvotes: integer('upvotes').notNull().default(0),
downvotes: integer('downvotes').notNull().default(0),
parentId: text('parent_id'), // For replies, null if it's a top-level comment
timestamp: text('timestamp')
.notNull()
.default(sql`CURRENT_TIMESTAMP`)
});

export const users = sqliteTable('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique()
});
How do I generate individual Comment and User types? Thanks!
5 Replies
Hypex
HypexOP3mo ago
using drizzle-kit as well
Mozzy
Mozzy3mo ago
Try this
No description
Mozzy
Mozzy3mo ago
Alternatively InferSelectModel<typeof cases>
Hypex
HypexOP3mo ago
it worked! tysm
Mozzy
Mozzy3mo ago
happy to help
Want results from more Discord servers?
Add your server