One canonical file per document version, prefix indexes for fast queries, schema-aware validation and versioning, field-level encryption with blind indexes, file-based RLS authorization, WORM append-only mode, and sync hooks when you want to replicate the root elsewhere.
FYLO parses a SQL dialect into collection operations so you can create, read, update, delete, and join document data without bringing in a separate database server.
import Fylo from "@d31ma/fylo"
const fylo = new Fylo({ root: "/mnt/fylo" })
// Create a collection
await fylo.executeSQL("CREATE TABLE users")
// Insert a document
await fylo.executeSQL(
'INSERT INTO users VALUES { "name": "Alice", "age": 28 }'
)
// Query with conditions
const results = await fylo.executeSQL(
'SELECT * FROM users WHERE age > 18 LIMIT 10'
)
// Cross-collection join
const joined = await fylo.joinDocs({
$leftCollection: "posts",
$rightCollection: "users",
$mode: "inner",
$on: { userId: { $eq: "id" } }
})
A single Bun-native storage engine with schema versioning, field-level encryption, file-based RLS, WORM append-only mode, and sync hooks.
Every document version is its own JSON file under a predictable path. Inspect, debug, and rebuild from the filesystem directly.
Zero-payload prefix indexes with local WAL+snapshot or S3 backends accelerate queries without storing document data in the index.
Async iterators stream live changes from an append-only filesystem event journal, so document and query subscriptions stay reactive.
Use collection methods like putData() and findDocs(), or run SQL-like commands through executeSQL().
FYLO leaves cloud replication to your app and gives you onWrite and onDelete hooks with await-sync and fire-and-forget modes.
CHEX schema validation, per-collection versioning with upgraders, file-based RLS authorization, and field-level AES-256-GCM encryption with HMAC blind indexes — all in one Bun-native package.
The current package writes to a local or mounted filesystem root and lets your application decide how that root gets mirrored to S3-compatible storage. Use sync hooks when you want replication behavior without handing over source-of-truth ownership.
root or FYLO_ROOT
await-sync or fire-and-forget for replication timing
event.path inside onWrite
onDelete hook
import Fylo from "@d31ma/fylo"
const fylo = new Fylo({
root: "/mnt/fylo",
syncMode: "await-sync",
sync: {
async onWrite(event) {
const file = Bun.file(event.path)
await myS3Client.putObject({
key: event.collection + "/" + event.docId + ".json",
body: await file.arrayBuffer()
})
},
async onDelete(event) {
await myS3Client.deleteObject({
key: event.collection + "/" + event.docId + ".json"
})
}
}
})
await fylo.createCollection("users")
await fylo.putData("users", {
name: "Ada",
role: "admin"
})
Drop a .env file in your project root. FYLO now prefers a single filesystem root with optional validation, encryption, and logging controls.
$encrypted fields. Used for AES-256-GCM field encryption.
FYLO keeps the source of truth on the filesystem and lets your app decide how that root gets synced anywhere else.