sqlite
@webda/sqlite
@webda/sqlite
Webda/SQLiteStore, Webda/SQLiteQueue and Webda/SQLitePubSub on Node's built-in node:sqlite
(Node >= 22.13, no third-party dependency). Without a persistence block the database lives in memory and is lost
on stop(), like MemoryStore; with persistence.path it is a single durable file.
| Need | Pick |
|---|---|
| Throw-away data in tests, zero setup | MemoryStore / MemoryQueue |
| A durable single file, WebdaQL pushed to SQL, queue and pub/sub on the same file | @webda/sqlite |
| One JSON file per object you can read by hand | @webda/fs |
| Several hosts, heavy concurrent traffic | @webda/postgres |
Modes
- Memory (no
persistence): one database per service, or one shared by the services giving the samedatabase.name(store + queue + pubsub in a test). - File (
persistence.path, relative to the application directory): WAL journal by default,synchronousNORMAL; every committed write is durable, so there is nodelayand no flush onstop(). Services of one process on the same path share one connection; other processes open their own. - Differences from
MemoryStore.persistence: nodelay;key,cipherandcompressionLevelare refused atinit()(node:sqlitehas no encryption or compression), never silently ignored.
Caveats
DatabaseSyncis synchronous: every statement blocks the event loop. Fits development, tests, CLI tools and small single-node applications; use PostgreSQL for heavy concurrent traffic.SQLitePubSubis a message log read through cursors: delivery is at-most-once per subscriber while subscribed, a subscriber offline longer thanretentionmisses messages (useSQLiteQueuefor guaranteed delivery), and it works inside one host only (in-process wake-up,PRAGMA data_versionpolling for other processes).- Node 22 prints an
ExperimentalWarningthe first timenode:sqliteis loaded; Node 24 does not.
Configuration
{
"services": {
"sqlite": {
"type": "Webda/SQLiteStore",
"persistence": { "path": "./.webda/app.sqlite" },
"models": ["MyApp/Post", "MyApp/Comment"],
"tables": { "MyApp/Comment": "comments" }
},
"jobs": { "type": "Webda/SQLiteQueue", "persistence": { "path": "./.webda/app.sqlite" } },
"events": { "type": "Webda/SQLitePubSub", "persistence": { "path": "./.webda/app.sqlite" } },
// tests / dev: same services, in memory, sharing one database
"testStore": { "type": "Webda/SQLiteStore", "database": { "name": "test" } }
}
}