Repository navigation
v1.3.0 – Auto-Increment Support & Validation
This release introduces support for traditional SQL-style AUTO_INCREMENT primary keys, with smarter insert handling, enhanced validation, and full test coverage.
🚀 New Features
✅ Auto-Increment ID Field Support
You can now define a struct field like this:
{
name: "id",
type: "number",
required: true,
length: 11,
default: "auto_increment"
}Behavior:
- On
create():- The
idis ignored automatically (not included in SQL). - If the user tries to pass
id, validation will fail.
- The
- On
update()/remove():- The
idis required and validated as a number.
- The
🔐 Validation Enhancements
The validatePayload() function now:
- Skips validation for
auto_incrementfields during insert - Rejects attempts to manually pass
idduring insert - Preserves strict type validation for updates/deletes
🧪 Tests Added
New tests verify:
- Successful creation without ID
- Proper update/delete using returned ID
- Failure if user tries to provide an
auto_incrementID on insert
✨ Example
await create('users', userStruct, {
title: 'Auto User'
});
// Returns: { success: true, data: { id: 1 } }await create('users', userStruct, {
id: 99,
title: 'Invalid'
});
// Fails: id should not be provided (auto_increment)✅ Summary
This update adds:
- Cleaner support for auto-incrementing numeric IDs
- Safer inserts with validation against misuse
- Consistent handling across all CRUD operations