Automattic / Automattic/mongoose

Make `Query#populate()` and `Document#populate()` no-ops when populating a path with no `ref` or `refPath`, and no `model` option

Open
#9,028 0 comments 0 reactions 0 assignees View on GitHub
backwards-breaking
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 5h
Merged PRs (30d)
32

Description

Re: #8946. When using `Model.populate()`, it makes sense to fall back to the `Model` if no `ref`. But when using `Query#populate()`, especially with nested `populate()`, this behavior can lead to some nasty surprises.

Contributor guide

Open the contributing guide

Research direction

Review issue #8946 and trace the Query#populate(), Document#populate(), and Model.populate() entry points, including nested populate() behavior. Confirm that Query#populate() and Document#populate() do nothing when a path has no ref or refPath and no model option, while Model.populate() retains its fallback behavior; add or update coverage for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.