-
Notifications
You must be signed in to change notification settings - Fork 1
backend sqlite HowTo
GitHub Action edited this page Apr 21, 2026
·
1 revision
This guide explains how to use the SQLite adapter for local development and testing.
SQLite is excellent for automated testing because you can use an in-memory database that is completely destroyed when the process exits.
import { Backend } from '@quatrain/backend'
import { SqliteAdapter } from '@quatrain/backend-sqlite'
// Use ':memory:' as the filename
const memoryAdapter = new SqliteAdapter({
config: {
filename: ':memory:'
}
})
Backend.addAdapter('default', memoryAdapter, true)
// In your test files:
// await myObject.save() // Saves instantly to RAMFor CLI tools or local data processing scripts, point the filename to a persistent path.
import { Backend } from '@quatrain/backend'
import { SqliteAdapter } from '@quatrain/backend-sqlite'
import path from 'path'
const dbPath = path.join(__dirname, '..', 'app.sqlite')
const localDb = new SqliteAdapter({
config: {
filename: dbPath
}
})
Backend.addAdapter('default', localDb, true)