Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows document _id to be generated on driver side for return #3

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

wess
Copy link
Contributor

@wess wess commented Oct 13, 2022

In insert, generate BSON\ObjectId if one doesn't exist in document, and insert it, instead of letting server generate _id.

@wess wess requested a review from fogelito October 13, 2022 15:48
@@ -376,6 +376,8 @@ public function insert(string $collection, array $document, array $options = [])
$docObj->{$key} = $value;
}

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

@fogelito fogelito Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice. Is it a unique ID in terms of race condition?
Then to assign to collection and remove lastInsertedDocument?

@fogelito fogelito merged commit f143e8f into main Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants