Is this a proper way to type a table and column?
I want to make certain crud action reusable in my codebase. Is this the proper way to type a SQLite table and column?
Load activeItem function
Load activeItem function
import { type InferSelectModel } from 'drizzle-orm';
import type { SQLiteColumn, SQLiteTable} from 'drizzle-orm/sqlite-core';
export async function loadActiveItems<T extends SQLiteTable>(
table: T,
orderBy: keyof InferSelectModel<T> = 'name'
) {
const activeColumn = table._.columns['active'];
const orderByColumn = table._.columns[orderBy];
return db.select().from(table).where(eq(activeColumn, true)).orderBy(orderByColumn);
}