Skip to content
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

feat(NODE-3568)!: ensure includeResultsMetadata is false by default #3786

Merged
merged 21 commits into from
Aug 4, 2023

Conversation

W-A-James
Copy link
Contributor

@W-A-James W-A-James commented Jul 26, 2023

Description

What is changing?

  • includeResultsMetadata is now set to false by default for findAndX family of methods
  • Updated uses of findAndX methods to set includeResultMetadata as appropriate
Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

findAndX family of methods will now set includeResultsMetadata to false by default

Previously, the default return type of this family of methods was a ModifyResult containing the found document and additional metadata. Now by default, they will return the found document or null.

// This has the same behaviour as providing `{ includeResultMetadata: false }` in the pre v6 driver
await collection.findOneAndUpdate(
	{ hello: 'world' },
	{ $set: { hello: 'WORLD' } });
// > { _id: new ObjectId("64c4204517f785be30795c92"), hello: 'world' }

// This has the same behaviour as providing no options in the pre v6 driver
await collection.findOneAndUpdate(
	{ hello: 'world' },
	{ $set: { hello: 'WORLD' } },
	{ includeResultMetadata: true } );
// > {
// >  lastErrorObject: { n: 1, updatedExisting: true },
// >  value: { _id: new ObjectId("64c4208b17f785be30795c93"), hello: 'world' },
// >  ok: 1
// > }

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@W-A-James W-A-James changed the title feat(NODE-3568)!: switch default feat(NODE-3568)!: ensure includeresultsMetadata is false by default Jul 28, 2023
@W-A-James W-A-James marked this pull request as ready for review July 28, 2023 21:17
@W-A-James W-A-James marked this pull request as draft July 31, 2023 13:56
@W-A-James W-A-James marked this pull request as ready for review July 31, 2023 17:05
@durran durran self-assigned this Aug 1, 2023
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 1, 2023
Copy link
Member

@durran durran left a comment

Choose a reason for hiding this comment

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

test/types/community/collection/findX.test-d.ts has some type tests to uncomment as part of this ticket. Also I expect those existing tests in that file to be failing, but they are not as the type definitions for findOneAndUpdate, findOneAndDelete, and findOneAndReplace are still typed as returning a ModifyResult when no options are passed or an options object without includeResultMetadata is provided - so those are incorrect with the new default.

src/client-side-encryption/clientEncryption.js Outdated Show resolved Hide resolved
test/integration/crud/find.test.js Outdated Show resolved Hide resolved
test/integration/node-specific/operation_examples.test.ts Outdated Show resolved Hide resolved
@W-A-James W-A-James changed the title feat(NODE-3568)!: ensure includeresultsMetadata is false by default feat(NODE-3568)!: ensure includeResultsMetadata is false by default Aug 1, 2023
@W-A-James W-A-James requested a review from durran August 1, 2023 19:28
Copy link
Member

@durran durran left a comment

Choose a reason for hiding this comment

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

Looking good, just a few minor suggestions. (I think the schema helpers type tests should just use the default). There may some linting fixes needed with my change suggestions.

test/types/community/collection/findX.test-d.ts Outdated Show resolved Hide resolved
test/types/community/collection/findX.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from durran August 2, 2023 13:29
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
test/types/schema_helpers.test-d.ts Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from durran August 3, 2023 14:12
durran
durran previously approved these changes Aug 3, 2023
@durran durran added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Aug 3, 2023
nbbeeken
nbbeeken previously approved these changes Aug 3, 2023
@durran
Copy link
Member

durran commented Aug 4, 2023

@W-A-James Can you fix the conflicts then I'll merge. Thanks!

@W-A-James W-A-James dismissed stale reviews from nbbeeken and durran via 2b79dff August 4, 2023 14:54
@W-A-James W-A-James requested a review from durran August 4, 2023 14:58
@durran durran merged commit fee8d3e into main Aug 4, 2023
@durran durran deleted the NODE-3568 branch August 4, 2023 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants