Skip to content

DOCSP-48893 Add get started with Mongoose tutorial #1138

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

stephmarie17
Copy link
Collaborator

@stephmarie17 stephmarie17 commented May 15, 2025

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-48893
Original page - https://www.mongodb.com/developer/languages/javascript/getting-started-with-mongodb-and-mongoose/

Staging Links

  • integrations
  • integrations/mongoose-get-started
  • 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?
    • Are the page titles greater than 20 characters long and SEO relevant?

    Copy link

    netlify bot commented May 15, 2025

    Deploy Preview for docs-node ready!

    Name Link
    🔨 Latest commit 19e4b10
    🔍 Latest deploy log https://app.netlify.com/projects/docs-node/deploys/684b0611995ccc0008c59b9e
    😎 Deploy Preview https://deploy-preview-1138--docs-node.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 project configuration.

    @stephmarie17 stephmarie17 marked this pull request as ready for review May 15, 2025 22:43
    Copy link
    Collaborator

    @jordan-smith721 jordan-smith721 left a comment

    Choose a reason for hiding this comment

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

    Nice work overall! I think this page could benefit by being converted into a stepped tutorial page (as mentioned in a few of my comments). Right now it reads like a reference page but has a lot of callbacks to previous sections and relies on running through each section in order. This could be confusing to anyone treating this like a regular reference-style page. Happy to discuss more about this and brainstorm ways to go about it!

    Copy link
    Collaborator

    @jordan-smith721 jordan-smith721 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 more fixes

    Copy link
    Collaborator

    @jordan-smith721 jordan-smith721 left a comment

    Choose a reason for hiding this comment

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

    LGTM w/ a couple minor fixes

    Copy link

    @vkarpov15 vkarpov15 left a comment

    Choose a reason for hiding this comment

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

    I had a few small comments and recommendations

    exists()
    ~~~~~~~~

    The ``exists()`` method returns either ``null`` or the ``ObjectId`` of a document that

    Choose a reason for hiding this comment

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

    Not strictly true, exists() returns either null or the first document that matches filter with the projection { _id: 1 } applied. So doesn't return an ObjectId, rather a POJO with an _id property.

    Also, I may be wrong but it seems a bit strange to introduce exists() before find(). exists() is helpful primarily for performance reasons, most basic applications don't need to use it.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Updated the exists() description and moved the whole Helper Methods section down to the Next Steps section.

    const blogFind = await Blog.findOne({ author: "Jess Garcia" });
    console.log(blogFind);

    const blogWhere = await Blog.where("author").equals("Jess Garcia");

    Choose a reason for hiding this comment

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

    It is slightly more idiomatic (but equivalent) to do Blog.find().where('author').equals('Jess Garcia').

    However, similar to exists(), I recommend not introducing where() so early, and you may want to exclude it entirely. Mongoose's chaining syntax has waned in popularity in recent years.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Updated the description to include general use cases.


    .. note::

    The Mongoose ``exec()`` function is an option of the ``findById()``

    Choose a reason for hiding this comment

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

    exec isn't an option. I think this section should clarify that findById() returns a Mongoose query object, and exec() executes the query and returns a promise.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Clarified.

    set ``required`` to true on any fields that you want to require. You can
    also validate the type and the formatting. In the preceding code, the
    ``slug`` field is defined as a ``string`` that is always in ``lowercase``.
    This validation takes the slug input and converts it to lowercase before

    Choose a reason for hiding this comment

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

    lowercase is implemented as a setter, not a validator. However, you also added a minLength property, which is a validator. You can update this paragraph to use minLength instead.

    Copy link
    Collaborator

    @rachel-mack rachel-mack Jun 11, 2025

    Choose a reason for hiding this comment

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

    Used minLength and added a custom setters section to the Next Steps section below.

    @rachel-mack rachel-mack requested a review from vkarpov15 June 12, 2025 15:49
    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.

    4 participants