db.dropAllUsers() in mongodb

dropAllUsers(writeConcern?)

This method removes all users from the current database. It returns the number of users dropped from the database.

The following db.dropAllUsers() operation drops every user from the products database.


use products

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


Example 1: When some users exist

MongoDB

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


Output:

2


Example 2: When no users exist

MongoDB

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


Output:

0

No comments:

Post a Comment