MongoDB Get Users

By Yashwant Chavan, Views 1721, Last updated on 01-Mar-2019

In this tutorial we will learn how to get all Users Information using MongoDB db.getUsers() method.

tags mongodb

MongoDB Get Users - db.getUsers()

Returns information for all the users in the database. Refer following getUsers() method syntax.

db.getUsers();

Mongodb Get Users Shell Command Example

> use technicalkeeda
switched to db technicalkeeda
> db.getUsers()
[
        {
                "_id" : "technicalkeeda.Yashwant",
                "user" : "Yashwant",
                "db" : "technicalkeeda",
                "customData" : {
                        "employeeId" : 1
                },
                "roles" : [
                        {
                                "role" : "readWrite",
                                "db" : "technicalkeeda"
                        },
                        {
                                "role" : "dbAdmin",
                                "db" : "technicalkeeda"
                        }
                ]
        },
        {
                "_id" : "technicalkeeda.scott",
                "user" : "scott",
                "db" : "technicalkeeda",
                "customData" : {
                        "employeeId" : 9999,
                        "employeeName" : "Yashwant",
                        "dept" : "IT"
                },
                "roles" : [
                        {
                                "role" : "readWrite",
                                "db" : "technicalkeeda"
                        }
                ]
        }
]
>
Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]