SQLite database synchronization across multiple clients via NAS using changelog-based conflict resolution. Version 0.9.0, actively maintained. Each client operates on a local SQLite database and synchronizes changes through a shared NAS directory. Key differentiators: automatic table discovery using schema introspection (no manual table list), SQLite trigger-based changelog for incremental sync, Last Write Wins conflict resolution using a timestamp column, support for per-table configuration (timestamp column name, delete protection), heartbeat mechanism to extend changelog retention, and an event system for monitoring sync progress. Requires Node.js >=16 and peer dependency better-sqlite3 >=11.0.0. ESM-only with built-in TypeScript types.
npm install sqlite-nas-syncNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a sync instance, performs a manual sync, starts periodic sync, and stops after 60 seconds.
Ensure the NAS filesystem supports O_DIRECT or use a local NAS mount with proper locking.
Add 'id' (TEXT) and 'updatedAt' columns to tables you want to sync, or use tableOptions to override column names.
Remove any autoDetect: false from config. If you need to exclude tables, use the 'excludeTables' option.
Adjust intervalMs based on your change frequency; monitor disk usage.
Add proper columns: ALTER TABLE your_table ADD COLUMN id TEXT NOT NULL PRIMARY KEY; ALTER TABLE your_table ADD COLUMN updatedAt TEXT; or set tableOptions for custom column names.
Change to ESM: use import { setupSync } from 'sqlite-nas-sync' or use dynamic import: const { setupSync } = await import('sqlite-nas-sync')Run: npm install better-sqlite3
Ensure the NAS directory exists and is writable: mkdir -p /mnt/nas/shared-db && chmod 755 /mnt/nas/shared-db
Drop the existing changelog table: DROP TABLE IF EXISTS _changelog; than re-run setupSync. Note: this will lose pending changes.