Skip to content

Commit

Permalink
Merge pull request #3 from utopia-php/fix-driver-gen-objectid
Browse files Browse the repository at this point in the history
Allows document _id to be generated on driver side for return
  • Loading branch information
fogelito authored Oct 18, 2022
2 parents a8b8090 + cf5a3d2 commit f143e8f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/MongoClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ public function insert(string $collection, array $document, array $options = [])
$docObj->{$key} = $value;
}

$docObj->_id ??= new BSON\ObjectId();

$this->query(array_merge([
MongoCommand::INSERT => $collection,
'documents' => [$docObj],
Expand Down

0 comments on commit f143e8f

Please sign in to comment.