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

Implement read and write concerns #40

Merged
merged 5 commits into from
Aug 19, 2023
Merged

Conversation

thekid
Copy link
Member

@thekid thekid commented Aug 19, 2023

This pull request adds readConcern() and writeConcern() method to the Options class.

ℹ️ This pull request does not include concern inheritance (connection -> database -> collection (-> session) -> command) as described in https://www.mongodb.com/docs/manual/reference/mongodb-defaults/. This requires us to know which command to pass readConcern to and which ones support writeConcern, as doing otherwise results in errors, see #11 (comment).

Read concerns

use com\mongodb\{Collection, Options};

$coll= $conn->collection('test', 'tests');
$coll->find([], (new Options())->readConcern('local'));

Write concerns

use com\mongodb\{Collection, Options, ObjectId};

$coll= $conn->collection('test', 'tests');
$coll->update(new ObjectId('...'), $operations, (new Options())->writeConcern('majority'));

See also

@thekid thekid added the enhancement New feature or request label Aug 19, 2023
@thekid thekid merged commit 67c884b into master Aug 19, 2023
18 checks passed
@thekid thekid deleted the feature/read-write-concerns branch August 19, 2023 14:47
@thekid
Copy link
Member Author

thekid commented Aug 19, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant