Automattic / Automattic/mongoose

[Refactor] Move Model.prototype.method into Document.prototype.method

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

Description

We currently have functions defined on `Model.prototype` which can be confusing to people looking at the docs, expecting a specific function to be on the `Document` section.

AFAICT there is virtually no benefit to defining methods on `Model.prototype` since `Model` returns a `Document` instance, we should define only statics on `Model`, and leave prototype methods to `Document`.

Am I missing something here? Let me know if those changes sound reasonable, and I'll put in a PR.

Contributor guide

Open the contributing guide

Research direction

The issue names Model.prototype and Document.prototype as the main entry points; inspect where their methods are defined and how the API documentation presents them. Determine which prototype methods should move while keeping statics on Model, then verify the existing tests and documentation checks; done means document methods live on Document and Model exposes only statics.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
backend, database
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.