Mongodb Get Users

By Yashwant Chavan, Views 1717, Date 10-Oct-2016

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 Chavan

Yashwant Chavan

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@gmail.com