-
Notifications
You must be signed in to change notification settings - Fork 533
RUBY-1972 RUBY-2001 RUBY-2148 Hint documentation #1948
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
Conversation
| Update Options | ||
| ~~~~~~~~~~~~~~ | ||
|
|
||
| To add options to an update command, specify them as key value pairs in the options |
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.
"key-value" pairs?
| result = artists.update_one( | ||
| { :name => 'Goldie' }, | ||
| { "$inc" => { :plays => 1 } }, | ||
| { hint: { _id: 1 } } |
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.
Is _id index used for the update rather than the find, i.e. this call searches for the document twice?
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.
This call doesn't search for documents twice! My understanding is that find just creates a View on the collection, and then the update command performs the search (with the specified index) and the update.
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.
In this case I am confused: how would the _id index be used with a query on name?
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'll think of a clearer example.
| - The session to use for this operation. | ||
| * - ``upsert`` | ||
| - Whether to upsert if the document doesn't exist. Cannot be used on | ||
| ``find_one_and_delete`` operation. |
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.
What about the :return_document that was in the example previously, does it still work?
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.
Yup! Thanks for pointing that out.
No description provided.