Skip to content

Commit

Permalink
utopia-php#285 Allow custom createdAt and updatedAt on createDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
fliitor authored Jun 23, 2023
1 parent 4035d3f commit 1eae97d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2527,8 +2527,8 @@ public function createDocument(string $collection, Document $document): Document
$document
->setAttribute('$id', empty($document->getId()) ? ID::unique() : $document->getId())
->setAttribute('$collection', $collection->getId())
->setAttribute('$createdAt', $time)
->setAttribute('$updatedAt', $time);
->setAttribute('$createdAt', empty($document->getCreatedAt()) ? $time : $document->getCreatedAt())
->setAttribute('$updatedAt', empty($document->getUpdatedAt()) ? $time : $document->getUpdatedAt());

$document = $this->encode($collection, $document);

Expand Down

0 comments on commit 1eae97d

Please sign in to comment.