How to get column names from Drizzle Table?

(not Types) but if want to console.log them
4 Replies
Mykhailo
Mykhailo11mo 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
MariuzMOP11mo ago
Where does getTableColumn function come from?
Mykhailo
Mykhailo11mo ago
from drizzle-orm
import { getTableColumns } from 'drizzle-orm';
import { getTableColumns } from 'drizzle-orm';
MariuzM
MariuzMOP11mo ago
Omg thank you 🙏
Want results from more Discord servers?
Add your server