Automattic / Automattic/mongoose

Disabling/Skipping plugins

Open
#7,376 4 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

**Do you want to request a *feature* or report a *bug*?**
Feature Request

**What is the current behavior?**
Is there a way to disable a plugin for a specific model? I've enabled timestamps and toObject transforms for all my schemas using a plugin. Unfortunately, my subdocument schemas also end up using that plugin, I do not want my subdocs to have timestamps or be transformed. Is there a way to turn off a plugin for a specific schema? I know you can opt-in by assigning the plugin to each model, but is there an opt-out option?

Super naive first thought:
Maybe something like `schema.prototype.skipPlugin(_nameOfPlugin_)`. Of course this would require plugins to be named, which could be useful..

**Please mention your node.js, mongoose and MongoDB version.**
All latest versions as of 12/27/2018

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests. Start by reviewing Mongoose's schema plugin API and how plugins propagate to subdocuments; define whether a schema-level opt-out or another mechanism is expected, and consider existing plugin application behavior before identifying tests that can demonstrate a plugin being skipped for selected schemas.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.