public function SanityCheck::buildCollectionstats in MongoDB 8.2
Build a list of the number of entries per collection in the default DB.
File
- modules/
mongodb_watchdog/ src/ Install/ SanityCheck.php, line 68
Class
- SanityCheck
- Class SanityCheck provides some reasonableness checks for MongoDB contents.
Namespace
Drupal\mongodb_watchdog\InstallCode
public function buildCollectionstats() : array {
/** @var \Drupal\mongodb\DatabaseFactory $databaseFactory */
$database = $this->dbFactory
->get(Logger::DB_LOGGER);
$this
->initBucketsList();
$collections = $database
->listCollections();
foreach ($collections as $collectionInfo) {
$name = $collectionInfo
->getName();
$collection = $database
->selectCollection($name);
$count = $collection
->countDocuments();
if (preg_match('/' . Logger::EVENT_COLLECTIONS_PATTERN . '/', $name)) {
$this
->store($count);
}
}
return $this->buckets;
}