Mobile app PoC (#281)

Initial checkin of mobile "native" app
This commit is contained in:
Zef Hemel
2023-01-08 12:24:12 +01:00
committed by GitHub
parent dc7de9d8f9
commit 0365673c41
61 changed files with 5190 additions and 155 deletions
+36
View File
@@ -0,0 +1,36 @@
import { Capacitor } from "../../mobile/deps.ts";
import { CapacitorSQLite } from "../deps.ts";
import { ISQLite } from "./sqlite_interface.ts";
export class CapacitorDb implements ISQLite {
constructor(readonly name: string) {
}
async init() {
await CapacitorSQLite.createConnection({
database: this.name,
});
await CapacitorSQLite.open({
database: this.name,
});
}
async query(sql: string, ...args: any[]) {
const result = await CapacitorSQLite.query({
statement: sql,
database: this.name,
values: args,
});
if (Capacitor.getPlatform() === "ios") {
return result.values!.slice(1);
}
return result.values!;
}
async execute(sql: string, ...args: any[]): Promise<number> {
return (await CapacitorSQLite.run({
statement: sql,
database: this.name,
values: args,
})).changes!.changes!;
}
}