All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- MySQL adapter support
- Redis caching layer
- Query builder interface
- Aggregation pipeline support
- Audit logging
Complete refactoring following CISCODE AuthKit patterns and best practices, with advanced features for production use.
-
Unified Repository API - Same interface for MongoDB and PostgreSQL
create(data)- Create new recordsfindById(id)- Find by primary keyfindOne(filter)- Find single record by filter (NEW)findAll(filter)- Find all matching recordsfindPage(options)- Paginated queriesupdateById(id, data)- Update by primary keydeleteById(id)- Delete by primary keycount(filter)- Count matching recordsexists(filter)- Check if records existupsert(filter, data)- Update or insert (NEW)distinct(field, filter)- Get distinct values (NEW)select(filter, fields)- Projection/field selection (NEW)
-
Transaction Support - ACID transactions with session management
withTransaction(callback, options)- Execute callback in transaction- Configurable retry logic for transient errors
- Automatic session handling
-
Bulk Operations - Efficient batch processing
insertMany(data)- Bulk insertupdateMany(filter, update)- Bulk updatedeleteMany(filter)- Bulk delete
-
Soft Delete - Non-destructive deletion
softDelete(id)- Mark as deletedrestore(id)- Restore deleted recordfindWithDeleted(filter)- Include deleted records- Configurable field name (default:
deletedAt/deleted_at)
-
Timestamps - Automatic created/updated tracking
createdAt/created_atfield on createupdatedAt/updated_atfield on update- Configurable field names
-
Health Checks - Database monitoring
healthCheck()- Connection status, response time, pool info
-
Connection Pool Configuration - Performance tuning (NEW)
PoolConfiginterface with min, max, idle timeout, acquire timeout- MongoDB: maxPoolSize, minPoolSize, serverSelectionTimeoutMS, socketTimeoutMS
- PostgreSQL: min, max, idleTimeoutMillis, acquireTimeoutMillis
-
Repository Hooks - Lifecycle event callbacks (NEW)
beforeCreate(context)- Called before insert, can modify dataafterCreate(entity)- Called after insertbeforeUpdate(context)- Called before update, can modify dataafterUpdate(entity)- Called after updatebeforeDelete(id)- Called before deleteafterDelete(success)- Called after delete
- DatabaseKitModule - NestJS module with DI support
forRoot(options)- Synchronous configurationforRootAsync(options)- Async configuration with factoryforFeature(token, config)- Multiple database connections
- MongoAdapter - MongoDB support via Mongoose
- Connection pooling
- Auto-reconnection
- Lean queries by default
- PostgresAdapter - PostgreSQL support via Knex
- Connection pooling
- Advanced filter operators (gt, gte, lt, lte, in, nin, like, etc.)
- Column whitelisting for security
- DatabaseService - Main facade for database operations
- Unified interface for both databases
- Connection lifecycle management
- Repository factory methods
- LoggerService - Structured logging
- NestJS Logger integration
- Context-aware logging
- @InjectDatabase() - Decorator for injecting DatabaseService
- @InjectDatabaseByToken(token) - Decorator for named connections
- DatabaseExceptionFilter - Global exception handling
- MongoDB error parsing
- PostgreSQL error parsing
- Consistent error response format
- Pagination helpers (
normalizePaginationOptions,calculatePagination) - Validation helpers (
isValidMongoId,isValidUuid,sanitizeFilter)
- Environment-driven configuration
- Config validation with fail-fast errors
- Connection string validation
- Comprehensive README with examples
- SECURITY.md with vulnerability reporting guidelines
- TROUBLESHOOTING.md with common issues
- CONTRIBUTING.md with development guidelines
- copilot-instructions.md for AI-assisted development
- Restructured to follow AuthKit patterns
- Separated concerns into adapters, services, and contracts
- Moved from
core/structure to proper layer separation
- All files now use kebab-case with suffixes
- Consistent class naming (PascalCase)
- Consistent function naming (camelCase)
- Added path aliases for clean imports
- Stricter TypeScript configuration
- Full type coverage with no implicit any
- N/A (initial release)
- Column whitelisting for PostgreSQL repositories
- Parameterized queries to prevent injection
- Error sanitization in exception filter
- No credentials in error messages
- N/A (initial release)
- Initial development and prototyping
- Basic MongoDB and PostgreSQL adapters
- Simple NestJS module integration
If you were using a pre-release version, follow these steps:
-
Update imports:
// Before import { Database } from '@ciscode/database-kit/core/database'; // After import { DatabaseService } from '@ciscode/database-kit';
-
Update module configuration:
// Before DatabaseModule.forRoot(config); // After DatabaseKitModule.forRoot({ config });
-
Update decorator usage:
// Before @InjectDatabase() private db: Database // After @InjectDatabase() private db: DatabaseService
-
Update repository creation:
// Methods remain the same const repo = db.createMongoRepository<User>({ model: UserModel });
We follow semantic versioning:
- Patch releases (x.x.X): Bug fixes, released as needed
- Minor releases (x.X.0): New features, ~monthly
- Major releases (X.0.0): Breaking changes, ~annually