SqlVFS keeps a filesystem in a database’s tables: a SQLite file, a Postgres
server, a Durable Object’s storage or a D1 database.
Install
Config
To mount Postgres, install
pg and pass its driver:
fs_inode: one row per file and directory, with its size and mtimefs_dentry: each entry’s name under its parent directoryfs_data: a file’s bytes, in rows of the database’s chunk size (4 KiB unless the database says otherwise)fs_config: the chunk size
Several mounts on one database
A mount serves one folder of its database,/ by default. Hand two mounts one
driver to serve the whole database at / and its /workspace folder as a mount
of its own:
capacitycounts every file in the database, whichever mount wrote it. Mounts on one driver with the samecapacityshare one count, so their writes together stay within it. Mounts on separate drivers count apart, even on one file, and together they can pass it.getStateandloadStatekeep and replace the mount’s own folder. A restore leaves the rest of the database as it was.
SqlVFS takes the same root and capacity over any driver, a Durable
Object’s storage among them.
VFS.md
The VFS.md an agent reads with SQL mounted at/<path>.