Skip to content

Instantly share code, notes, and snippets.

@Alex-Kaff
Alex-Kaff / README.md
Last active December 8, 2025 05:50
MongoDBExtendedService for FeathersJS with the MongoDB adapter

MongoDBExtendedService

Extends Feathers MongoDB service to disable expensive countDocuments() by default and allows using full schema types in underscore-prefixed methods (_create, _patch, _update). It also adds new helpful methods, supporting batch patches and finds, as well as an upsert method, and easy access to a typed mongodb Collection object. Also supports firing the default CRUD events for underscore-prefixed methods with _fireEvent param.

Why This Exists

  1. Performance: countDocuments() is a heavy MongoDB operation. This service skips it by default unless explicitly requested via _paginate.countDocuments: true (need to add it to query schema for external use).
  2. Type Flexibility: Standard Feathers MongoDB methods use restricted types (ResultData, ResultPatch). The underscore methods accept Partial (full schema) for internal operations.