How to get column names from Drizzle Table?

(not Types) but if want to console.log them
4 Replies
Mykhailo
Mykhailo10mo ago
Hello, @MariuzM! You can do something like this
const columnNames: string[] = Object.values(getTableColumns(<yourSchema>)).map((col) => col.name);

console.log(columnNames);
const columnNames: string[] = Object.values(getTableColumns(<yourSchema>)).map((col) => col.name);

console.log(columnNames);
MariuzM
MariuzMOP10mo ago
Where does getTableColumn function come from?
Mykhailo
Mykhailo10mo ago
from drizzle-orm
import { getTableColumns } from 'drizzle-orm';
import { getTableColumns } from 'drizzle-orm';
MariuzM
MariuzMOP10mo ago
Omg thank you 🙏
Want results from more Discord servers?
Add your server