Skip to content
New issue

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

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

Already on GitHub? # to your account

DOCSP-45194: Retrieve data #96

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Dec 11, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-45194

Staging Links

  • read
  • read/retrieve
  • get-started/create-a-connection-string
  • get-started/create-a-deployment
  • index
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?

    Copy link

    netlify bot commented Dec 11, 2024

    Deploy Preview for docs-ruby ready!

    Name Link
    🔨 Latest commit c05e895
    🔍 Latest deploy log https://app.netlify.com/sites/docs-ruby/deploys/675b57d6ca565b0008507a83
    😎 Deploy Preview https://deploy-preview-96--docs-ruby.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link
    Collaborator

    @mcmorisi mcmorisi left a comment

    Choose a reason for hiding this comment

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

    LGTM with some questions!

    source/includes/read/retrieve.rb Show resolved Hide resolved

    In this guide, you can learn how to use the {+driver-short+} to retrieve
    data from a MongoDB collection by using **read operations**. You can call the
    ``find`` method on a collection to retrieve documents that match a set of
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Echoes a similar question elsewhere in the review – should I not refer to methods by name using parentheses (i.e. find())?

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    asked in the group slack channel!

    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Parentheses are optional in Ruby as long as it isn't ambiguous. By convention, we typically omit parens for zero-argument calls (e.g. client.close), single-argument calls (often when the argument is a literal value, e.g. puts "hello"), and when the only argument is a Hash instance (in which case the curly braces are also optional, e.g. Foo.new a: 1, b: 'hi', c: var).

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Makes sense, thank you!

    @norareidy norareidy requested a review from jamis December 11, 2024 20:36
    Copy link
    Contributor

    @jamis jamis left a comment

    Choose a reason for hiding this comment

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

    Just a few suggestions to make the Ruby code a bit more idiomatic. 👍


    # Finds one document with a "name" value of "LinkedIn"
    # start-find-one
    document = collection.find({ 'name' => 'LinkedIn' }).first
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    This isn't wrong, but it might be more idiomatically written as:

    Suggested change
    document = collection.find({ 'name' => 'LinkedIn' }).first
    document = collection.find(name: 'LinkedIn').first


    # Finds documents with a "founded_year" value of 1970
    # start-find-many
    results = collection.find({ 'founded_year' => 1970 })
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    As before, more idiomatically written as:

    Suggested change
    results = collection.find({ 'founded_year' => 1970 })
    results = collection.find(founded_year: 1970)


    # Finds and prints up to 2 documents with a "number_of_employees" value of 1000
    # start-modify
    limit_results = collection.find({ 'number_of_employees' => 1000 }).limit(2)
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Suggested change
    limit_results = collection.find({ 'number_of_employees' => 1000 }).limit(2)
    limit_results = collection.find(number_of_employees: 1000).limit(2)

    puts doc
    end
    # end-modify
    ensure
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Wrapping this all in a begin/ensure/end block isn't wrong, but the initializer for Mongo::Client will do it all for you if you pass a block to it, e.g.:

    Mongo::Client.new(uri) do |client|
      # processing here, with the `client` reference.
      # the client will be closed automatically when the block terminates.
    end

    This idiom is preferred for a lot of things in Ruby, where resources need to be cleaned up after being used, like with File.open and network operations.

    source/read.txt Outdated
    :values: reference

    .. meta::
    :description: Learn how to use the Ruby driver to read data to MongoDB.
    Copy link
    Contributor

    @jamis jamis Dec 11, 2024

    Choose a reason for hiding this comment

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

    Suggested change
    :description: Learn how to use the Ruby driver to read data to MongoDB.
    :description: Learn how to use the Ruby driver to read data from MongoDB.


    In this guide, you can learn how to use the {+driver-short+} to retrieve
    data from a MongoDB collection by using **read operations**. You can call the
    ``find`` method on a collection to retrieve documents that match a set of
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Parentheses are optional in Ruby as long as it isn't ambiguous. By convention, we typically omit parens for zero-argument calls (e.g. client.close), single-argument calls (often when the argument is a literal value, e.g. puts "hello"), and when the only argument is a Hash instance (in which case the curly braces are also optional, e.g. Foo.new a: 1, b: 'hi', c: var).

    @norareidy norareidy merged commit 8899aef into mongodb:standardization Dec 12, 2024
    5 checks passed
    @norareidy norareidy deleted the DOCSP-45194-retrieve branch December 12, 2024 21:57
    norareidy added a commit that referenced this pull request Jan 31, 2025
    * add actions
    
    * Update add-netlify-links.yml (#90) (#91)
    
    (cherry picked from commit c2b53c0)
    
    Co-authored-by: Mike Woofter <108414937+mongoKart@users.noreply.github.com>
    
    * DOCSP-45177 - Create a client (#88)
    
    * DOCSP-45170: Landing page and cleanup (#89)
    
    * DOCSP-45170: Landing page and cleanup
    
    * copy snooty file
    
    * fix toc
    
    * netlify script
    
    * fix
    
    * put old files in folder
    
    * MW feedback
    
    * DOCSP-45171: Download and Install (#92)
    
    * DOCSP-45171: Download and Install
    
    * snooty
    
    * landing page
    
    * MW feedback
    
    * DR feedback
    
    * fix
    
    * DOCSP-45173: Deployment & connection string (#94)
    
    * DOCSP-45173: Deployment & connection string
    
    * edits
    
    * edit image
    
    * SA feedback
    
    * DOCSP-45187: Update
    
    * Fixes
    
    * Fix
    
    * DOCSP-45175: Connect to MongoDB (#95)
    
    * DOCSP-45175: Connect to MongoDB
    
    * fixes
    
    * edits, next steps
    
    * JS feedback
    
    * DR feedback
    
    * Fix
    
    * MW feedback
    
    * DOCSP-45194: Retrieve data (#96)
    
    * DOCSP-45194: Retrieve data
    
    * edits
    
    * build errors
    
    * api links
    
    * JB feedback
    
    * DOCSP-45186: Insert
    
    * Fix
    
    * Fix
    
    * Fix
    
    * DOCSP-45212 Compatibility (#97)
    
    * NR feedback
    
    * MW feedback + adjusting code to be more idiomatic
    
    * DOCSP-45189: Delete
    
    * Fixes
    
    * Fix
    
    * DOCSP-45188: Replace
    
    * JS feedback
    
    * DOCSP-45203 Single Field Indexes (#100)
    
    * add files
    
    * Update add-netlify-links.yml (#90)
    
    * DOCSP-45076: Document that count supports different filters from countDocuments
    
    * Test fix
    
    * Fix
    
    * Try again
    
    * Never mind
    
    * NR suggestion
    
    * DOCSP-45203 Single Field Indexes
    
    * Edits
    
    * edits
    
    * get rid of old commit work
    
    * code spacing
    
    * Stephanie's reiview
    
    * Tech review code improvements
    
    * update api links
    
    * add a space at eof
    
    * update listing description
    
    * add context to ex query code comment
    
    * style edit on prev
    
    ---------
    
    Co-authored-by: Mike Woofter <108414937+mongoKart@users.noreply.github.com>
    Co-authored-by: Michael Morisi <michael.morisi@mongodb.com>
    
    * Technical feedback
    
    * DOCSP-45188: Replace
    
    * Fixes
    
    * JS feedback
    
    * DOCSP-45210 What's New (#99)
    
    * DOCSP-45195: Project fields (#105)
    
    * DOCSP-45195: Project fields
    
    * edits
    
    * SA feedback
    
    * DOCSP-45196: Limit, skip, and sort (#109)
    
    * DOCSP-45196: Limit, skip, and sort
    
    * code output
    
    * fixes
    
    * DOCSP-45193: Specify queries (#102)
    
    * DOCSP-45193: Specify queries
    
    * edits
    
    * wording
    
    * LM feedback
    
    * JB feedback
    
    * DOCSP-45197: Count documents (#110)
    
    * DOCSP-45197: Count documents
    
    * edits
    
    * code fix
    
    * JS feedback
    
    * DOCSP-45198: Distinct values (#111)
    
    * DOCSP-45198: Distinct values
    
    * edits
    
    * RR feedback
    
    * DOCSP-45185: Write landing page
    
    * Fixes
    
    * MW feedback
    
    * DOCSP-45204 Compound Index (#106)
    
    * DOCSP-45204 Compound Index
    
    * fix ref
    
    * fix code comment spacing
    
    * specify create one ref
    
    * bold single field
    
    * tech review comment
    
    * remove comments from snippet and spacing fix
    
    * repeated text
    
    * DOCSP-45205 Multikey Indexes (#103)
    
    * DOCSP-45205 Multikey Indexes
    
    * first draft
    
    * edits
    
    * remove quotes from key name
    
    * remove comments from code snippets
    
    * DOCSP-45190: Bulk Write
    
    * Fixes
    
    * link fix
    
    * Fix
    
    * JS feedback
    
    * DOCSP-45182-ruby-databases-collection-2
    
    * added api links
    
    * links
    
    * better link
    
    * style guide and link fixes
    
    * api fixes
    
    * testing bundler
    
    * DOCSP-45191: GridFS
    
    * Fix
    
    * added separate text file, deleted some pages that were added on from a new pr
    
    * DOCSP-45214 Add transactions (#115)
    
    * feedback
    
    * more feedback
    
    * link
    
    * final link
    
    * DOCSP-45191: MW feedback
    
    * small change
    
    * small change
    
    * revert change
    
    * DOCSP-45184-ruby-replica-sets
    
    * fix errors and links
    
    * fixes
    
    * link fix
    
    * syntax
    
    * last fixes
    
    * DOCSP-45183-time-series-collections
    
    * DOCSP-45181: Stable API
    
    * Fix
    
    * half feedback
    
    * LM feedback
    
    * DOCSP-45199: Cursors (#120)
    
    * DOCSP-45199: Cursors
    
    * edits
    
    * fix link
    
    * JS feedback
    
    * tech review
    
    * other half of feedback
    
    * style guide
    
    * added more copy
    
    * added page
    
    * formatting
    
    * trying for output
    
    * again
    
    * formatting
    
    * DOCSP-45191: GridFS follow-up
    
    * Fix
    
    * Jamis technical feedback
    
    * add
    
    * feedback
    
    * ahh
    
    * toctree
    
    * api links
    
    * feedback
    
    * toctree and errors
    
    * file
    
    * errors
    
    * DOCSP-45209: Authentication landing + Authentication mechanisms
    
    * Fixes
    
    * feedback
    
    * fix build
    
    * update toctree
    
    * Reorganize auth mechanisms to separate pages
    
    * Fix
    
    * redoing feedback that got merged out
    
    * toctree
    
    * Fix
    
    * fix typo
    
    * mark troubleshooting todo
    
    * feedback
    
    * DOCSP-45192-read-data-page
    
    * Tweak the Kerberos and IAM pages
    
    * Fix
    
    * wrote page
    
    * fix links
    
    * last link fix
    
    * feedback
    
    * keyword
    
    * keyword 2
    
    * feedback
    
    * fix link
    
    * MW feedback, round 1
    
    * Fix
    
    * Fix
    
    * Kerberos file tweaks, also fixes
    
    * Fix
    
    * DOCSP-45176: Run a command
    
    * Fix
    
    * RM feedback
    
    * DOCSP-45202 Index Overview (#112)
    
    * DOCSP-45202 Index Overview
    
    * edits
    
    * fix ref
    
    * atlas search updates
    
    * small fix
    
    * add api section, edit atlas search examples
    
    * edits
    
    * tech review
    
    * DOCSP-45206 Atlas Search Index (#113)
    
    * DOCSP-45206 Atlas Search Indexes
    
    * first draft
    
    * draft code
    
    * edits
    
    * using native api
    
    * edits
    
    * emphasize lines
    
    * RM typo
    
    * var rename
    
    * code spacing
    
    * DOCSP-45178 Choose a Connection Target (#125)
    
    * DOCSP-45178 Choose a Connection Target
    
    * edits and add page to TOC
    
    * more small edits
    
    * last edits
    
    * no hyper linked period
    
    * coe improvements
    
    * stable api single quote
    
    * feedback
    
    * feedback
    
    * fix toctree issue
    
    * DOCSP-45192-read-data-page
    
    * quotes
    
    * label
    
    * link
    
    * Second round of MW feedback
    
    * Fixes
    
    * Fix
    
    * MW feedback
    
    * feedback
    
    * fix typo
    
    * DOCSP-45200: Change streams (#123)
    
    * DOCSP-45200: Change streams
    
    * edits
    
    * JB feedback
    
    * Jamis feedback
    
    * DOCSP-45179 Configure TLS (#129)
    
    * Configure TLS
    
    * insecure tls
    
    * edits
    
    * monospace
    
    * 1/2 MW edits
    
    * last of MW revisions and table
    
    * table reformat
    
    * spacing edit
    
    * formatting edits
    
    * format
    
    * edit
    
    * MW last comments
    
    * small change
    
    * tech review
    
    * DOCSP-45207 Transform data with aggregation (#131)
    
    * DOCSP-45812 Connection Options (#132)
    
    * DOCSP-45812 Connection Options
    
    * edits
    
    * more edits
    
    * more edits
    
    * format
    
    * format
    
    * RM review
    
    * another link
    
    * add timeout_ms
    
    * remove deprecated options
    
    * DOCSP-45211 Upgrade major versions (#134)
    
    * DOCSP-46860: In-use encryption (#138)
    
    * DOCSP-45201 Cluster monitoring (#133)
    
    * DOCSP-45201 Cluster monitoring
    
    * first draft
    
    * remove eevrything not about cluster monitoring:
    
    * table changes
    
    * review
    
    * final few changes
    
    * NR review comments
    
    * NR comments
    
    * look through
    
    * tech review comments
    
    * DOCSP-45180 Server selection (#135)
    
    * DOCSP-45188 Server selection
    
    * quick add
    
    * remove page
    
    * spacing
    
    * review comment
    
    * same edit
    
    * tech review
    
    * DOCSP-46862 Issues & Help (#139)
    
    * DOCSP-46862 Issues & Help
    
    * edits
    
    * internal review
    
    * weird build fail
    
    * build mysteriously good again
    
    * DOCSP-42104 CSOT (#136)
    
    * first draft
    
    * revisions
    
    * edit
    
    * edits
    
    * code edits
    
    * Rea comments
    
    * edits
    
    * last internal comments
    
    * tech review + add atlas search api refs
    
    * edit to api refs
    
    * code comment edit
    
    * fix code example option name
    
    * DOCSP-46650: Cleanup (#137)
    
    * DOCSP-46650: Cleanup
    
    * redirects
    
    * more cleanup
    
    * rename, test api link
    
    * api links
    
    * fix toc api link
    
    * monitoring, edits
    
    * check api links
    
    * LM feedback
    
    * snooty
    
    * remove old redirects
    
    * LM feedback
    
    ---------
    
    Co-authored-by: Mike Woofter <108414937+mongoKart@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: Michael Morisi <michael.morisi@mongodb.com>
    Co-authored-by: Stephanie <52582720+stephmarie17@users.noreply.github.com>
    Co-authored-by: lindseymoore <71525840+lindseymoore@users.noreply.github.com>
    Co-authored-by: Grace Miller <grace.miller@mongodb.com>
    Co-authored-by: rustagir <rea.rustagi@mongodb.com>
    Co-authored-by: gmiller-mdb <135852653+gmiller-mdb@users.noreply.github.com>
    # for free to join this conversation on GitHub. Already have an account? # to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants