v4 is a major release that fundamentally shifts Skalex from a general-purpose local document store to an AI-first, isomorphic, zero-dependency database. The core API is largely preserved but several conventions have changed. Work through each section below before upgrading.
v4 uses globalThis.crypto.subtle for AES-256-GCM encryption and a runtime-aware ID generator that uses crypto.randomBytes on Node.js/Bun/Deno and falls back to globalThis.crypto.getRandomValues in the browser. The Node.js path requires Node.js 18 or later.
node --version # must be >= 18.0.0Sort direction now follows the MongoDB standard: 1 for ascending, -1 for descending.
await products.find({}, { sort: { price: "asc" } });
await products.find({}, { sort: { price: "desc" } });await products.find({}, { sort: { price: 1 } }); // ascending
await products.find({}, { sort: { price: -1 } }); // descendingReplace all string sort directions with numeric equivalents across every find() call site.
Documents created with insertOne and insertMany now include an updatedAt field equal to createdAt at creation time. This is not a breaking change but may affect code that checks for the absence of updatedAt.
db.import() no longer accepts a format parameter and no longer supports CSV files. The previous CSV parser split on commas without handling quoted fields, which meant any value containing a comma was silently corrupted. Round-trips with collection.export({ format: "csv" }) produced incorrect data.
await db.import("./data/users.csv", "csv");CSV import is not supported. Use JSON as the interchange format instead:
// Export from your old source as JSON, then import:
await db.import("./data/users.json");- Export any existing CSV data to JSON before upgrading. If your data originated from
collection.export({ format: "csv" }), re-export it as JSON first:
// Run this against your v3 database before upgrading
await collection.export({}, { format: "json", name: "users" });- Replace every
db.import(path, "csv")call withdb.import(path)pointing at the JSON file. collection.export({ format: "csv" })still works for exporting - only import of CSV was removed.