git-sqlite-vfs 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +21 -23
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,40 +1,38 @@
1
1
  # git-sqlite-vfs
2
2
 
3
- A Git-versioned SQLite Database powered by a custom Virtual File System (VFS).
3
+ A Git-versioned SQLite database utilizing a custom Virtual File System (VFS).
4
4
 
5
- By integrating native SQLite, Drizzle ORM, and libSQL with Git's version control capabilities, `git-sqlite-vfs` allows you to version, diff, and merge your application's database in a manner similar to source code. It is compatible with both **Node.js** and **Deno**.
5
+ By integrating SQLite, Drizzle ORM, and libSQL with Git, `git-sqlite-vfs` enables versioning, diffing, and merging of SQLite databases. It is compatible with Node.js and Deno.
6
6
 
7
7
  ## Architecture
8
8
 
9
- Standard SQLite databases are stored as a single flat file. This structure presents challenges for version control, as a minor insertion can result in widespread byte shifts across the file, reducing the effectiveness of delta-compression and making binary merge conflicts difficult to resolve.
9
+ Standard SQLite databases are stored as a single file. This limits version control compatibility, as minor insertions cause cascading byte shifts, negating delta-compression and creating unresolvable binary merge conflicts.
10
10
 
11
- This package provides a loadable SQLite C Extension that overrides the default VFS behavior. It shards the database into 4KB deterministic binary pages within a specified directory (e.g. `.my-db`).
11
+ This package provides a loadable SQLite C extension that overrides the default VFS behavior. It shards the database into deterministic 4KB binary pages within a specified directory (e.g. `.my-db`).
12
12
 
13
- During a Git merge, a provided `git-merge-sqlitevfs` driver integrates with Git's conflict resolution pipeline to reconcile binary B-Tree page conflicts, maintaining data integrity.
13
+ During a Git merge, a custom `git-merge-sqlitevfs` driver integrates with Git's conflict resolution pipeline to reconcile B-Tree page conflicts.
14
14
 
15
15
  ## Installation
16
16
 
17
- Install the package alongside your libSQL and Drizzle ORM dependencies:
18
-
19
17
  ```bash
20
18
  npm install git-sqlite-vfs @libsql/client drizzle-orm
21
19
  ```
22
20
 
23
21
  ## Git Configuration
24
22
 
25
- To enable Git versioning and binary merging, the repository must be configured to use the custom merge driver. This is done **automatically** when you call `bootstrapGitVFS()`:
23
+ The repository must be configured to use the custom merge driver. This configuration occurs automatically when `bootstrapGitVFS()` is called:
26
24
 
27
- 1. It registers `git-merge-sqlitevfs` as a custom Git merge driver in the local `.git/config`.
28
- 2. It adds or appends to a `.gitattributes` file in the repository root to route all files matching your configured directory (e.g., `.my-db/*`) through the custom merge driver.
29
- 3. It creates or updates a `.gitignore` to ignore SQLite transient files (`*-journal`, `*-wal`, `*-shm`).
25
+ 1. Registers `git-merge-sqlitevfs` as a custom Git merge driver in the local `.git/config`.
26
+ 2. Updates `.gitattributes` in the repository root to route files matching the configured directory (e.g., `.my-db/*`) through the custom merge driver.
27
+ 3. Updates `.gitignore` to ignore SQLite transient files (`*-journal`, `*-wal`, `*-shm`).
30
28
 
31
- ### Safe alongside Source Code
29
+ ### Source Code Compatibility
32
30
 
33
- The custom SQLite merge driver **will not interfere with the merging of standard source code or text files**. By utilizing the `.gitattributes` file, Git explicitly scopes the custom driver strictly to the files within your designated database directory (e.g., `.my-db/* merge=sqlitevfs`). All other files in your repository will continue to use Git's default text-based merge algorithms.
31
+ The custom SQLite merge driver scopes to the designated database directory via `.gitattributes`. Other repository files continue using Git's default text-based merge algorithms.
34
32
 
35
33
  ## Usage
36
34
 
37
- The VFS works in both Node.js and Deno environments. By calling the `bootstrapGitVFS()` method prior to initializing `@libsql/client`, the extension is loaded process-wide.
35
+ The VFS operates in Node.js and Deno environments. Calling `bootstrapGitVFS()` prior to initializing `@libsql/client` loads the extension process-wide.
38
36
 
39
37
  ### Example with `@libsql/client` and Drizzle ORM
40
38
 
@@ -44,42 +42,42 @@ import { drizzle } from 'drizzle-orm/libsql';
44
42
  import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
45
43
  import { bootstrapGitVFS } from 'git-sqlite-vfs';
46
44
 
47
- // 1. Load the native extension process-wide and set the VFS directory
45
+ // Load the native extension process-wide and set the VFS directory
48
46
  await bootstrapGitVFS({ dir: '.my-db' });
49
47
 
50
- // 2. Initialize the database connection using a standard file: URL
48
+ // Initialize the database connection using a file URL
51
49
  const client = createClient({
52
50
  url: 'file:.my-db/local.db'
53
51
  });
54
52
 
55
- // 3. Wrap with Drizzle ORM
53
+ // Wrap with Drizzle ORM
56
54
  const db = drizzle(client);
57
55
 
58
- // 4. Define the schema
56
+ // Define the schema
59
57
  const users = sqliteTable('users', {
60
58
  id: integer('id').primaryKey(),
61
59
  name: text('name')
62
60
  });
63
61
 
64
- // 5. Execute queries. File I/O is intercepted by the Git VFS.
62
+ // Execute queries
65
63
  await db.insert(users).values({ id: 1, name: 'Alice' });
66
64
  const allUsers = await db.select().from(users);
67
65
 
68
66
  console.log(allUsers);
69
67
  ```
70
68
 
71
- ## Preventing Repository Bloat
69
+ ## Database Compaction
72
70
 
73
- Because SQLite often zeroes out deleted data pages rather than shrinking the database file size, "zombie" `.bin` pages may accumulate in the repository over time. To allow the Git VFS to automatically garbage-collect these unused chunks, configure SQLite to use `FULL` auto-vacuuming and `DELETE` journaling.
71
+ SQLite often zeroes out deleted data pages rather than shrinking the file size, causing unneeded `.bin` pages to remain. To allow the Git VFS to remove these unused shards, configure SQLite to use `FULL` auto-vacuuming and `DELETE` journaling.
74
72
 
75
- Execute these PRAGMA statements when initializing the database connection:
73
+ Execute these PRAGMA statements during connection initialization:
76
74
 
77
75
  ```sql
78
76
  PRAGMA auto_vacuum = FULL;
79
77
  PRAGMA journal_mode = DELETE;
80
78
  ```
81
79
 
82
- Alternatively, you can run `VACUUM;` periodically. When SQLite explicitly reduces the database file size, the underlying VFS `xTruncate` implementation will remove the out-of-bounds `.bin` shards, keeping the repository history compressed.
80
+ Alternatively, executing `VACUUM;` periodically reduces the database file size, and the VFS `xTruncate` implementation will remove out-of-bounds `.bin` shards.
83
81
 
84
82
  ## Compatibility
85
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-sqlite-vfs",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "A Git-Versioned SQLite Database via a Custom Virtual File System (VFS)",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",