Skip to content

Commit

Permalink
createCollection time series support
Browse files Browse the repository at this point in the history
Create collection time series support doctrine#2533
  • Loading branch information
cyildirim committed Jul 3, 2023
1 parent a66e407 commit 9733bad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Doctrine/ODM/MongoDB/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(protected DocumentManager $dm, protected ClassMetada
public function ensureIndexes(?int $maxTimeMs = null, ?WriteConcern $writeConcern = null, bool $background = false): void
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView()) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView() || $class->isTimeSeriesDocument) {
continue;
}

Expand Down Expand Up @@ -339,7 +339,7 @@ public function updateValidators(?int $maxTimeMs = null, ?WriteConcern $writeCon
public function updateDocumentValidator(string $documentName, ?int $maxTimeMs = null, ?WriteConcern $writeConcern = null): void
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView() || $class->isFile) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView() || $class->isFile || $class->isTimeSeriesDocument) {
throw new InvalidArgumentException('Cannot update validators for files, views, mapped super classes, embedded documents or aggregation result documents.');
}

Expand Down Expand Up @@ -447,6 +447,8 @@ public function createDocumentCollection(string $documentName, ?int $maxTimeMs =
}

$options = [
'timeseries' => $class->getCollectionTimeseries(),
'expireAfterSeconds' => $class->getCollectionExpireAfterSeconds(),
'capped' => $class->getCollectionCapped(),
'size' => $class->getCollectionSize(),
'max' => $class->getCollectionMax(),
Expand Down

0 comments on commit 9733bad

Please sign in to comment.