commands/list.ts (view raw)
1import { Table } from "@cliffy/table";
2import type { DatabaseSync } from "node:sqlite";
3
4export default (db: DatabaseSync) => {
5 const recipes = db.prepare("SELECT * FROM recipes").all();
6 const cells = recipes.map((recipe) => [
7 recipe.id as string,
8 recipe.name as string,
9 recipe.url as string,
10 recipe.createdAt as string,
11 ]);
12 const table = new Table(["ID", "Name", "URL", "Created At"], ...cells);
13
14 console.log(table.border().toString());
15};