v3.3.0
July 15, 2025
  • You can now pass TypeScript generics to all service methods for precise type inference and enhanced type safety. This helps you catch mistakes at compile time and improves your development experience.
const user = await userService.findOne({ _id: '...' });

// user.subscription is available if defined in schema
user.subscription

// Pass a generic to override the provided type
// TypeScript will enforce the structure you specify:
const admin = await userService.findOne<Admin>({ _id: '...' });

// TypeScript Error:
// Property 'subscription' doesn't exist on type 'Admin'
admin.subscription
  • Added escapeRegExp option to service methods, enabling automatic escaping of $regex filter values to prevent special characters from being interpreted as patterns.

Before

const users = await userService.find({
  name: { $regex: 'John\' }, 
});

// Throws error 'Regular expression is invalid: \\ at end of pattern'
// Provided string by user needs to be escaped before query

After

const service = db.createService<User>(DATABASE_DOCUMENTS.USERS, {
  schemaValidator: (obj) => userSchema.parseAsync(obj),
  escapeRegExp: true,
});

// No need to escape string before query
const users = await userService.find({
  name: { $regex: 'John\' },
});
  • Upgraded mongodb dependency to v6.17.0 and updated related dependencies (mocha, @types/mocha, zod, etc.).
  • Fixed all known vulnerabilities.
v3.2.0
October 10, 2023
  • Upgraded mongodb dependency from v4.10.0 to v6.1.0 (requires Node.js >=16.16.0).
  • Cleaned up legacy MongoDB connection options.
  • Improved typings and compatibility for bulk operations and index management.
v3.1.2
December 1, 2022
  • Synchronized README.md with the documentation website for consistency and completeness.
v3.1.1
October 24, 2022
  • Fixed: atomic.updateOne and atomic.updateMany now use readConfig for query validation, ensuring consistent handling of soft-delete and query options.
v3.1.0
October 17, 2022
  • Refactored Service and Database classes for better type safety:
    • IDocument now extends MongoDB’s Document and requires _id: string.
    • Many methods now use stricter generic constraints (<T extends IDocument>).
  • Added support for custom schema validation via schemaValidator in ServiceOptions.
  • Introduced new config types: CreateConfig, ReadConfig, UpdateConfig, DeleteConfig for more granular operation control.
  • Improved transaction support: database.withTransaction now uses default transaction options and better error handling.
  • Enhanced logging for event publishing and warnings in development mode.
  • Internal: Cleaned up and unified method signatures, improved property type checks, and removed legacy/duplicate code.
v3.0.4
September 7, 2022
  • Changed all date fields (createdOn, updatedOn, deletedOn) to use native Date objects instead of ISO strings.
v3.0.3
August 3, 2022
  • service.find() options page and perPage are now optional; defaults are set internally if omitted.
v3.0.2
June 24, 2022
  • eventBus.onUpdated now supports generics for improved type safety.
  • service.aggregate() now returns an array of results directly.
v3.0.1
June 21, 2022
  • In-memory event listeners now require an entity name (e.g., onUpdated('users', ...)).
  • Added logging for published in-memory events.
v3.0.0
March 28, 2022

The release includes a lot of changes to make sure that the package is compatible with the latest MongoDB version. Most notable changes:

v2.1.0
October 15, 2020

Features

Manager

createService

v2.0.0
September 29, 2020
  • Update dependencies.

Breaking Changes

Manager

createQueryService

  • Rename validateSchema option to validate.
  • Change addCreatedOnField default to true.
  • Change addUpdatedOnField default to true.

createService

  • Rename validateSchema option to validate.
  • Change addCreatedOnField default to true.
  • Change addUpdatedOnField default to true.

Query Service

  • Remove generateId method.
  • Remove expectDocument method.

Service

Features

Manager

createQueryService

  • Add useStringId option.

createService

  • Add useStringId option.

Query Service

Service

v1.1.0
June 25, 2019
  • Update dependencies.
  • Fix required version of the Node.js.

Breaking Changes

  • Now update function will work via set operator. It means the new doc will be the result of merge of the old doc and the provided one.
v1.0.0
May 23, 2018
  • Update dependencies.
  • Add tests.
  • Fix required version of the Node.js.

Breaking Changes

  • Now, by default, we do not add the fields createdOn and updatedOn automatically to the model. If you want to save the current behavior, add the appropriate addCreatedOnField and addUpdatedOnField options to the service definitions.
v0.3.1
December 16, 2017
  • Stop using deprecated method ensureIndex of the monk.
v0.3.0
October 24, 2017
  • Add ability to create custom methods for service and query service.
  • Add tests.
v0.2.0
October 12, 2017
  • Add support of the joi for validating data schema.
  • Add tests for validating of the schema.