pull/109/head
Zef Hemel 2022-10-17 16:28:58 +02:00
parent e7a240127c
commit 6013426212
5 changed files with 15 additions and 11 deletions

View File

@ -29,7 +29,7 @@ jobs:
# uses: denoland/setup-deno@v1 # uses: denoland/setup-deno@v1
uses: denoland/setup-deno@d4873ceeec10de6275fecd1f94b6985369d40231 uses: denoland/setup-deno@d4873ceeec10de6275fecd1f94b6985369d40231
with: with:
deno-version: v1.x deno-version: v1.26.1
# Uncomment this step to verify the use of 'deno fmt' on each commit. # Uncomment this step to verify the use of 'deno fmt' on each commit.
# - name: Verify formatting # - name: Verify formatting

View File

@ -13,12 +13,14 @@ export type KV = {
}; };
export function ensureTable(db: SQLite, tableName: string) { export function ensureTable(db: SQLite, tableName: string) {
const stmt = db.prepare( const result = db.query(
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`, `SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
[tableName],
); );
const result = stmt.all(tableName);
if (result.length === 0) { if (result.length === 0) {
db.exec(`CREATE TABLE ${tableName} (key STRING PRIMARY KEY, value TEXT);`); db.execute(
`CREATE TABLE ${tableName} (key STRING PRIMARY KEY, value TEXT);`,
);
console.log(`Created table ${tableName}`); console.log(`Created table ${tableName}`);
} }
return Promise.resolve(); return Promise.resolve();
@ -76,7 +78,7 @@ export function asyncQuery<T extends Record<string, unknown>>(
...params: any[] ...params: any[]
): Promise<T[]> { ): Promise<T[]> {
// console.log("Querying", query, params); // console.log("Querying", query, params);
return Promise.resolve(db.prepare(query).all<T>(params)); return Promise.resolve(db.queryEntries(query, params));
} }
export function asyncExecute( export function asyncExecute(
@ -85,7 +87,8 @@ export function asyncExecute(
...params: any[] ...params: any[]
): Promise<number> { ): Promise<number> {
// console.log("Exdecting", query, params); // console.log("Exdecting", query, params);
return Promise.resolve(db.exec(query, params)); db.query(query, params);
return Promise.resolve(db.changes);
} }
export function storeSyscalls( export function storeSyscalls(

View File

@ -1,3 +1,3 @@
export * from "../common/deps.ts"; 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"; export { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";

View File

@ -22,15 +22,15 @@ export type KV = {
const tableName = "page_index"; const tableName = "page_index";
export function ensureTable(db: SQLite): Promise<void> { 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=?`, `SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
[tableName],
); );
const result = stmt.all(tableName);
if (result.length === 0) { if (result.length === 0) {
db.exec( db.execute(
`CREATE TABLE ${tableName} (key STRING, page STRING, value TEXT, PRIMARY KEY (page, key));`, `CREATE TABLE ${tableName} (key STRING, page STRING, value TEXT, PRIMARY KEY (page, key));`,
); );
db.exec( db.execute(
`CREATE INDEX ${tableName}_idx ON ${tableName}(key);`, `CREATE INDEX ${tableName}_idx ON ${tableName}(key);`,
); );
console.log(`Created table ${tableName}`); console.log(`Created table ${tableName}`);

View File

@ -6,6 +6,7 @@ release.
## 0.1.3 ## 0.1.3
* Frontmatter support! You can now use front matter in your markdown, to do this start your page with `---` and end it with `---`. This will now be the preferred way to define page meta data (although the old way will still work). The old `/meta` slash command has now been replaced with `/front-matter`. * Frontmatter support! You can now use front matter in your markdown, to do this start your page with `---` and end it with `---`. This will now be the preferred way to define page meta data (although the old way will still work). The old `/meta` slash command has now been replaced with `/front-matter`.
* Tags are now indexed as page meta without the prefixing `#` character, the reason is to make this compatible with Obsidian. You can now attach tags to your page either by just using a `#tag` at the top level of your page, or by adding a `tags` attribute to your front matter. * Tags are now indexed as page meta without the prefixing `#` character, the reason is to make this compatible with Obsidian. You can now attach tags to your page either by just using a `#tag` at the top level of your page, or by adding a `tags` attribute to your front matter.
* Silver Bullet now runs on Windows!
--- ---