+1
-1
@@ -1,3 +1,3 @@
|
||||
export * from "../common/deps.ts";
|
||||
export { Database as SQLite } from "https://deno.land/x/sqlite3@0.6.1/mod.ts";
|
||||
export { DB as SQLite } from "https://deno.land/x/sqlite@v3.5.0/mod.ts";
|
||||
export { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
|
||||
|
||||
@@ -22,15 +22,15 @@ export type KV = {
|
||||
const tableName = "page_index";
|
||||
|
||||
export function ensureTable(db: SQLite): Promise<void> {
|
||||
const stmt = db.prepare(
|
||||
const result = db.query(
|
||||
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
|
||||
[tableName],
|
||||
);
|
||||
const result = stmt.all(tableName);
|
||||
if (result.length === 0) {
|
||||
db.exec(
|
||||
db.execute(
|
||||
`CREATE TABLE ${tableName} (key STRING, page STRING, value TEXT, PRIMARY KEY (page, key));`,
|
||||
);
|
||||
db.exec(
|
||||
db.execute(
|
||||
`CREATE INDEX ${tableName}_idx ON ${tableName}(key);`,
|
||||
);
|
||||
console.log(`Created table ${tableName}`);
|
||||
|
||||
Reference in New Issue
Block a user