You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
MongoDB\Collection::getNamespace()
Definition
MongoDB\Collection::getNamespace()Returns the namespace of the collection. A namespace is the canonical name of an index or collection in MongoDB.
function getNamespace(): string
Return Values
The namespace of this collection as a string.
Example
The following returns the namespace of the zips collection in the test
database.
$collection = (new MongoDB\Client)->test->zips; echo $collection->getNamespace();
The output would then resemble:
test.zips