MCPcopy Create free account
hub / github.com/observablehq/framework / describe

Method describe

src/client/stdlib/sqlite.js:49–72  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

47 }));
48 }
49 async describe(object) {
50 const rows = await (object === undefined
51 ? this.query("SELECT name FROM sqlite_master WHERE type = 'table'")
52 : this.query("SELECT * FROM pragma_table_info(?)", [object]));
53 if (!rows.length) throw new Error("Not found");
54 const {columns} = rows;
55 return element("table", {value: rows}, [
56 element("thead", [
57 element(
58 "tr",
59 columns.map((c) => element("th", [text(c)]))
60 )
61 ]),
62 element(
63 "tbody",
64 rows.map((r) =>
65 element(
66 "tr",
67 columns.map((c) => element("td", [text(r[c])]))
68 )
69 )
70 )
71 ]);
72 }
73 async sql() {
74 return this.query(...this.queryTag.apply(this, arguments));
75 }

Callers

nothing calls this directly

Calls 3

queryMethod · 0.95
elementFunction · 0.85
textFunction · 0.70

Tested by

no test coverage detected