v0.81.0
0.81.0 (2025-04-25)
Features
Performance Improvements
BREAKING CHANGES
- Removed generic types from SqlFactory.
- Moved database configuration into SqlFactory. Static properties like TABLE, LIMIT_DEFAULT, and SORT_KEY must now be defined inside each factory class.
- Required every entity to have a corresponding SqlFactory (at minimum, to define the TABLE name).
- Converted instance property methods into publicly overridable methods.
- Removed dependency on QueryResultRow
- Updated services to use entity types directly instead of generics.
Example of the new SqlFactory and Service pattern:
import { DefaultSqlFactory } from "@dzangolab/fastify-slonik";
class UserSqlFactory extends DefaultSqlFactory {
static readonly TABLE = "users";
}
export default UserSqlFactory;import { BaseService } from "@dzangolab/fastify-slonik";
import UserSqlFactory from "./sqlFactory";
import {
User,
UserCreateInput,
UserUpdateInput,
} from "../../types";
class UserService extends BaseService<
User,
UsereCreateInput,
UserUpdateInput
> {
get factory(): UserSqlFactory {
return super.factory as UserSqlFactory;
}
get sqlFactoryClass() {
return UserSqlFactory;
}
}
export default UserService;Extending functionality by overriding methods:
class UserService extends BaseService<
User,
UsereCreateInput,
UserUpdateInput
> {
async update(data: C): Promise<User | undefined> {
const user = await super.update(data);
// Add extra actions.
return user;
}
}
export default UserService;Migration Guide (for upgrading from 0.80.1 or earlier)
- Ensure every entity has a associated SqlFactory (at minimum, to define the
TABLEname). - Remove generic types from SqlFactory definitions.
- Move all the database config inside SqlFactory (static properties like TABLE, LIMIT_DEFAULT, and SORT_KEY)
- Refactor service methods to be publicly overridable instead of instance properties.
- Update services to use the entity type directly, instead of relying on generics.
Refer to: