-
Notifications
You must be signed in to change notification settings - Fork 28
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
DOCSP-45200: Change streams #123
DOCSP-45200: Change streams #123
Conversation
✅ Deploy Preview for docs-ruby ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
enum = stream.to_enum | ||
while (doc = enum.next) | ||
puts doc | ||
break if doc['operationType'] == 'invalidate' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using stream#each
will be simpler, and more idiomatic:
enum = stream.to_enum | |
while (doc = enum.next) | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end | |
stream.each do |doc| | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end |
enum = stream.to_enum | ||
while (doc = enum.next) | ||
puts doc | ||
break if doc['operationType'] == 'invalidate' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly converting the stream to an enum is usually a hint that you're doing something the hard way. Prefer stream#each
when iterating over a stream:
enum = stream.to_enum | |
while (doc = enum.next) | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end | |
stream.each do |doc| | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end |
enum = stream.to_enum | ||
while (doc = enum.next) | ||
puts doc | ||
break if doc['operationType'] == 'invalidate' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum = stream.to_enum | |
while (doc = enum.next) | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end | |
stream.each do |doc| | |
puts doc | |
break if doc['operationType'] == 'invalidate' | |
end |
source/read/change-streams.txt
Outdated
When using the {+driver-short+}, you can call the ``watch`` method to return a | ||
``Mongo::Collection::View::ChangeStream`` object. Then, you can convert the change | ||
stream to an ``Enumerator`` object and iterate through its content to monitor data | ||
changes, such as updates, insertions, and deletions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to convert the change stream to an enumerator, as the stream is already iterable. Maybe something like the following?
When using the {+driver-short+}, you can call the ``watch`` method to return a | |
``Mongo::Collection::View::ChangeStream`` object. Then, you can convert the change | |
stream to an ``Enumerator`` object and iterate through its content to monitor data | |
changes, such as updates, insertions, and deletions. | |
When using the {+driver-short+}, you can call the ``watch`` method to return a | |
``Mongo::Collection::View::ChangeStream`` object. Then, you can iterate through | |
its content to monitor data changes, such as updates, insertions, and deletions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this wording, updated! Sorry about that confusion
source/read/change-streams.txt
Outdated
The following example opens a change stream on the ``restaurants`` collection, | ||
converts the change stream to an ``Enumerator``, and outputs changes as they occur: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, there's no need to convert the stream to an enumerator.
The following example opens a change stream on the ``restaurants`` collection, | |
converts the change stream to an ``Enumerator``, and outputs changes as they occur: | |
The following example opens a change stream on the ``restaurants`` collection | |
and outputs changes as they occur: |
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-45200
Staging Links
Self-Review Checklist