Download src/lib/db/helpers/metaStore.js from heyeyydss/api9nin: direct link, hf CLI and curl.
- Browser
- Download file 887 Bytes
-
https://huggingface.co/spaces/heyeyydss/api9nin/resolve/main/src/lib/db/helpers/metaStore.js
- Command line
-
hf download hf://spaces/heyeyydss/api9nin/src/lib/db/helpers/metaStore.js
-
curl -L -o metaStore.js https://huggingface.co/spaces/heyeyydss/api9nin/resolve/main/src/lib/db/helpers/metaStore.js
887 Bytes
| import { getAdapter } from "../driver.js"; | |
| export async function getMeta(key, fallback = null) { | |
| const db = await getAdapter(); | |
| const row = db.get(`SELECT value FROM _meta WHERE key = ?`, [key]); | |
| return row ? row.value : fallback; | |
| } | |
| export async function setMeta(key, value) { | |
| const db = await getAdapter(); | |
| db.run(`INSERT INTO _meta(key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, [key, String(value)]); | |
| } | |
| // Sync versions for use during migration (adapter passed directly) | |
| export function getMetaSync(adapter, key, fallback = null) { | |
| const row = adapter.get(`SELECT value FROM _meta WHERE key = ?`, [key]); | |
| return row ? row.value : fallback; | |
| } | |
| export function setMetaSync(adapter, key, value) { | |
| adapter.run(`INSERT INTO _meta(key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, [key, String(value)]); | |
| } | |