protected function collectionExists($collectionName): bool
    {
        foreach ($this->database->listCollections() as $collection) {
            if ($collection->getName() === $collectionName) {
                return true;
            }
        }

        return false;
    }
protected function collectionExists($collectionName): bool
    {
        foreach ($this->database->listCollections() as $collection) {
            if ($collection->getName() === $collectionName) {
                return true;
            }
        }

        return false;
    }
protected function collectionExists ( $ collectionName ) : bool { foreach ( $ this -> database -> listCollections ( ) as $ collection ) { if ( $ collection -> getName ( ) === $ collectionName ) { return true ; } } return false ; }
Checks if a collection name exists on the Mongo database.

@param string $collectionName The collection name to check.

@return bool True if the collection exists, false if not.
Checks if a collection name exists on the Mongo database .