We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e31c869 commit 9c2d597Copy full SHA for 9c2d597
2 files changed
package.json
@@ -39,4 +39,3 @@
39
"@types/node": "^25.5.2"
40
}
41
42
-
src/index.ts
@@ -1,11 +1,17 @@
1
import { DatabaseSync, DatabaseSyncOptions } from "node:sqlite"
2
export { version } from "../package.json"
3
4
-export class SqliteMap<K, V> {
+export class SqliteMap<K extends string, V> {
5
private db: DatabaseSync
6
7
constructor(path: string, options?: DatabaseSyncOptions) {
8
this.db = new DatabaseSync(path, options)
9
this.db.exec("CREATE TABLE IF NOT EXISTS map (key TEXT PRIMARY KEY, value TEXT)")
10
11
+
12
+ set(key: K, data: V): this {
13
+ const stmt = this.db.prepare(`INSERT OR REPLACE INTO cache (key, value) VALUES (?, ?)`)
14
+ stmt.run(String(key), JSON.stringify(data), Date.now())
15
+ return this
16
+ }
17
0 commit comments