8000 fix(model): disallow Model.findOneAndUpdate(update) and fix TypeScript types re: findOneAndUpdate by vkarpov15 · Pull Request #15365 · Automattic/mongoose · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(model): disallow Model.findOneAndUpdate( 8000 update) and fix TypeScript types re: findOneAndUpdate #15365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

vkarpov15
Copy link
Collaborator

Summary

Apply #15199 to findOneAndUpdate(). This looks to be the last model function where we replace conditions with update if there's only 1 arg.

Examples

@vkarpov15 vkarpov15 added this to the 8.14 milestone Apr 21, 2025
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR disallows the use of Model.findOneAndUpdate() with a single update argument and updates the corresponding documentation and TypeScript types.

  • Removed tests for single-argument usage in the test suite
  • Updated documentation in both the query and model files to clarify the new behavior
  • Removed the legacy single-argument handling block in the model implementation

Reviewed Changes

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

File Description
test/model.findOneAndUpdate.test.js Removed tests that invoked findOneAndUpdate() with a single update argument
lib/query.js Updated the function signature documentation to use "filter" instead of "conditions"
lib/model.js Updated docs and removed legacy behavior for single-argument usage, reflecting the new disallowed usage
Comments suppressed due to low confidence (1)

test/model.findOneAndUpdate.test.js:328

  • Consider adding explicit tests that verify calling findOneAndUpdate with a single argument now throws an appropriate error or is disallowed, to clearly document the expected behavior.
query = M.findOneAndUpdate({ $set: { date: now } });

@vkarpov15 vkarpov15 changed the base branch from master to 8.14 April 23, 2025 15:41
@vkarpov15 vkarpov15 merged commit 3ae50df into 8.14 Apr 23, 2025
64 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-15363 branch April 23, 2025 15:42
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
0