db.dropUser() in mongodb

dropUser(username, writeConcern?)

This method removes the user from the current database. If the user exists in the database then it will return true. Otherwise, it will return false.


The following db.dropUser() operation drops the "userName" user on the products database.

use products

db.dropUser("userName", {w: "majority", wtimeout: 5000})


Example 1: When the user exists

MongoDB


db.dropUser("userName", {w: "majority", wtimeout: 5000})

Output:

true


Example 2: When the user does not exist

MongoDB


db.dropUser("userName", {w: "majority", wtimeout: 5000})

Output:

false

No comments:

Post a Comment