| 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 | } |