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-5432)!: remove addUser and collection.stats #22

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

nbbeeken
Copy link
Collaborator

@nbbeeken nbbeeken commented Jul 21, 2023

Description

What is changing?

mongodb/node-mongodb-native#3781

Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

db.addUser() and admin.addUser() removed

The deprecate addUser APIs have been removed. The driver maintains support across many server versions and the createUser command has support for different features based on the server's version, since applications can generally write code to work against a uniform and perhaps more modern server the path forward is for applications to send the createUser command directly.

See createUser documentation: https://www.mongodb.com/docs/manual/reference/command/createUser/

const db = client.db('admin');
// Example addUser usage
db.addUser(
  'myUsername', 
  'myPassword', 
  { roles: [ { role: 'readWrite', db: 'mflix' } ] },
  (error) => {
    if (error) {
      console.log('Failed to create user', error);
      return;
    }
    console.log('Created user!');
  }
);
// Example equivalent command usage
db.command(
  { 
    createUser: 'myUsername', 
    pwd: 'myPassword', 
    roles: [ { role: 'readWrite', db: 'mflix' } ] 
  },
  (error) => {
    if (error) {
      console.log('Failed to create user', error);
      return;
    }
    console.log('Created user!');
  }
);

collection.stats() removed

The collStats command is deprecated starting in server v6.2 so the driver is removing it's bespoke helper in this major release. The collStats command is still usable from manually running it via await db.command(). However, the recommended migration is to use the $collStats aggregation stage. You can find more information here: $collStats

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

@nbbeeken nbbeeken requested a review from W-A-James July 24, 2023 21:43
@W-A-James W-A-James merged commit 0a3b91d into main Jul 26, 2023
6 checks passed
@W-A-James W-A-James deleted the NODE-5432-removals branch July 26, 2023 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants