Skip to content

Set() stage builder #512

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

Closed
wants to merge 3 commits into from
Closed

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Mar 11, 2025

Pull Request Info

PR Reviewing Guidelines

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

Staging Links

  • fundamentals/builders
  • 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 Mar 11, 2025

    Deploy Preview for docs-csharp ready!

    Name Link
    🔨 Latest commit 2a4bf2e
    🔍 Latest deploy log https://app.netlify.com/sites/docs-csharp/deploys/67f7ce5635ce9400084d8b4f
    😎 Deploy Preview https://deploy-preview-512--docs-csharp.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

    @mongoKart mongoKart left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @norareidy norareidy requested review from a team and rstam and removed request for a team March 12, 2025 14:04

    var pipeline = new EmptyPipelineDefinition<Flower>()
    .Match(matchFilter)
    .Set(fields);
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Have you tried executing this?

    Most likely it will throw an exception when reading the results from the server because the C# declaration for Flower does not have a Color property.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Ah yep, I added Color to the Flower class while testing and just added it to the page. But does that defeat the purpose of Set()?

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Good point. It looks like the API for Set is defective. Let me discuss with the team.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    The current implementation of Set assumes that you are using Set to change the value of existing fields.

    I will be creating a JIRA ticket to cover the scenario where you want to use Set to add new fields. This will require adding a TNewResult type parameter to represent the new result with the new additional fields.

    But we should wait until that gets implemented to update the documentation.

    So for now let's document setting existing fields.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    p.s. I wrote the above comment a long time ago but apparently didn't submit it because it still showed as "pending".

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    So I think that means we should not merge this PR at this time.

    @norareidy norareidy requested a review from rstam April 4, 2025 17:29
    Add Fields to Collection Documents
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    You can add new fields to existing documents in a collection
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    This might be a bit misleading because the documents in the collection are NOT modified.

    The new fields are only added to the documents going through the pipeline, the original documents that are input to the pipeline are unchanged.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Okay, I removed mentions of "collection" and just kept it as "You can add new fields to documents"


    var pipeline = new EmptyPipelineDefinition<Flower>()
    .Match(matchFilter)
    .Set(fields);
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Good point. It looks like the API for Set is defective. Let me discuss with the team.

    @mongoKart
    Copy link
    Collaborator

    @norareidy I added a C# example to the $set Server page; do you think we can close this PR?

    https://www.mongodb.com/docs/upcoming/reference/operator/aggregation/set/#examples

    @norareidy
    Copy link
    Collaborator Author

    @norareidy I added a C# example to the $set Server page; do you think we can close this PR?

    https://www.mongodb.com/docs/upcoming/reference/operator/aggregation/set/#examples

    If Set() is now working as expected I can just merge this PR; @rstam are there any updates on that?

    @mongoKart mongoKart requested a review from rstam July 11, 2025 14:31
    Copy link
    Collaborator

    @rstam rstam left a comment

    Choose a reason for hiding this comment

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

    See comments

    @norareidy norareidy closed this Jul 15, 2025
    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.

    3 participants