w3resource

MongoDB: db.getName() method

db.getName

The db.getName() method is used to return the name of the current database.

Syntax:

db.getName()

Returns: the current database name.

Example: MongoDB: db.getName() method

The following statement will return the name of the current database.

db.getName();

Output:

db.getName();
test

Retrieve the restaurants data from here

Previous: db.getMongo() method
Next: db.getPrevError() method



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/mongodb/shell-methods/database/db-getName.php