Skip to content

feat(exec): add filter option to execPreSync and execPostSync - #44

Merged
vkarpov15 merged 5 commits into
mongoosejs:masterfrom
AbdelrahmanHafez:feat/add-filter-option-to-exec-pre-sync
Jan 29, 2026
Merged

feat(exec): add filter option to execPreSync and execPostSync#44
vkarpov15 merged 5 commits into
mongoosejs:masterfrom
AbdelrahmanHafez:feat/add-filter-option-to-exec-pre-sync

Conversation

@AbdelrahmanHafez

@AbdelrahmanHafez AbdelrahmanHafez commented Jan 15, 2026

Copy link
Copy Markdown
Member

This PR:

  1. Adds filter option to execPreSync and execPostSync, they're needed to handle pre/post init in feat: add option to skip middleware Automattic/mongoose#15883
  2. Adds context parameter to createWrapperSync for compatibility with createWrapper, mongoose usage was already assuming context and options which didn't exist.
  3. Adds a getOptions option to createWrapperSync to enable users to send options through to execPreSync and execPostSync.
  4. Add back the documentation block deleted by auto generated README file in feat(exec): add filter option to allow executing hooks based on a filter function #43.

@AbdelrahmanHafez
AbdelrahmanHafez force-pushed the feat/add-filter-option-to-exec-pre-sync branch from 11bc3e4 to 0f03371 Compare January 15, 2026 12:29
@AbdelrahmanHafez
AbdelrahmanHafez marked this pull request as draft January 15, 2026 12:33
@AbdelrahmanHafez
AbdelrahmanHafez marked this pull request as ready for review January 15, 2026 13:11
@vkarpov15
vkarpov15 requested a review from Copilot January 29, 2026 15:46
@vkarpov15
vkarpov15 merged commit 391fb3d into mongoosejs:master Jan 29, 2026
8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds hook filtering support to the synchronous hook execution APIs and extends createWrapperSync() to better match createWrapper() behavior (context handling + forwarding options), along with restoring generated README documentation content.

Changes:

  • Add { filter } support to execPreSync() and execPostSync() to selectively run hooks.
  • Extend createWrapperSync() to accept an explicit context and a getOptions() callback to forward options into pre/post sync execution.
  • Restore the pre-hooks documentation block in the generated README output.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
index.js Adds filter option to sync exec methods and extends createWrapperSync() with context + getOptions() forwarding.
test/pre.test.js Adds coverage for execPreSync(..., { filter }) and null/undefined filter behavior.
test/post.test.js Adds coverage for execPostSync(..., { filter }) and null/undefined filter behavior.
test/wrap.test.js Adds coverage for createWrapperSync() context selection and getOptions()-driven hook filtering.
README.md Reintroduces the pre-hooks documentation content in the generated README section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.js
Comment thread index.js
Comment thread index.js
Comment thread index.js
@AbdelrahmanHafez
AbdelrahmanHafez deleted the feat/add-filter-option-to-exec-pre-sync branch January 29, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants