v0.5.0
This release introduces powerful new features, significant architectural improvements, and a more streamlined developer experience. Key highlights include a new merge method for partial updates, support for a wide array of advanced data types, and a decoupled API for defining indexes.
✨ Features
Section titled “✨ Features”- Partial Updates with
merge: Introducedinstance.merge(db, data)andModel.merge(db, data)for performing partial record updates, aligning with SurrealDB’sMERGEstatement. This is now the recommended way to update specific fields without fetching and sending the entire record. - Expanded Data Type Support: Added comprehensive, type-safe support for most of SurrealDB’s advanced data types, including:
Field.any()Field.decimal()Field.float()Field.int()Field.bytes()Field.duration()Field.uuid()Field.geometry()(with type-safe definitions for specific geometry types)
- Flexible Fields: Added a
flexible: trueoption toField.object()andField.custom()to support SurrealDB’sFLEXIBLEkeyword, allowing for dynamic, schema-less fields within structured models. - Decoupled Index Definitions: Indexes are now defined separately from tables using a new
Index.define()API. This improves separation of concerns and simplifies the table definition API.
🚀 Improvements & Refactors
Section titled “🚀 Improvements & Refactors”- Unified Schema API: The
applySchemaandgenerateFullSchemaQlfunctions now accept a single array of definable items (e.g.,[User, UserEmailIndex]), simplifying the schema management process. - Clearer Table Definition:
Table.definehas been replaced withTable.normal()andTable.relation()to make the distinction between standard and edge tables explicit and type-safe. - Instance-level
delete: Added aninstance.delete(db)method for more intuitive record deletion.
🛠️ Fixes
Section titled “🛠️ Fixes”- Schema Generation: Fixed an issue where the schema generator would emit redundant
WHEREclauses for raw permission strings. - Query Engine: Correctly implemented support for
varsbindings in queries and enforced thatorderByclauses use a validorderdirection. - Field Definitions: Prevented the schema generator from emitting duplicate
field[*]definitions for array fields. - Package Compatibility: Set the
modulefield inpackage.jsontodist/index.jsto ensure correct module resolution in various environments.
📚 Documentation
Section titled “📚 Documentation”- JSDoc Coverage: Added comprehensive JSDoc comments with examples to all core functions, types, and classes, providing rich IntelliSense in supported editors.
- New Guides & Cookbook: Added a detailed tutorial, a cookbook with practical recipes (e.g., pagination, soft-delete), and updated the README with a quick-start guide.
- Starlight Migration: All documentation has been migrated to a modern, searchable Starlight-powered site.
💥 Breaking Changes
Section titled “💥 Breaking Changes”- The
indexesproperty has been removed fromTable.defineoptions. Indexes must now be created separately using the newIndex.define()function. Table.defineis deprecated. UseTable.normal()for standard tables andTable.relation()for edge tables instead.