Node.js + Express 5 backend with flat NDJSON key-value store (borrowed from electronics-inventory). Sequential integer IDs per namespace. Vanilla JS SPA with filters for status, priority, and tags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
456 B
JavaScript
19 lines
456 B
JavaScript
import { Simple_KeyValue_Store } from './kv-store.mjs';
|
|
import { mkdirSync } from 'node:fs';
|
|
|
|
mkdirSync('./data', { recursive: true });
|
|
|
|
const id_store = new Simple_KeyValue_Store('./data/ids.ndjson', {
|
|
auto_load: true,
|
|
auto_store: true,
|
|
debounce_flush_timeout: 1000,
|
|
});
|
|
|
|
export function next_id(namespace) {
|
|
const key = `seq:${namespace}`;
|
|
const current = id_store.get(key) ?? 0;
|
|
const next = current + 1;
|
|
id_store.set(key, next);
|
|
return next;
|
|
}
|