Skip to content
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

Adds support for updateMany changes #574

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lewishazell
Copy link

@lewishazell lewishazell commented Oct 21, 2024

Hey!

I really wanted to see this feature when using the extension and I could see it was requested a while ago in #449. While running update through runCommand is an option, it's harder to discern exactly what is happening.

This change adds mongodb:updateMany as a change type which takes a filter and update.

For example,

<mongodb:runCommand>
    <mongodb:command>
        {
            update: "atmosphericData",
            updates: [{
                q: { },
                u: [{ 
                    $set: { 
                        temperature: {
                            $replaceAll: {
                                input: "$temperature",
                                find: "c",
                                replacement: "C"
                            }
                        }
                    }
                }]
            }]}
    </mongodb:command>
</mongodb:runCommand>

Can now be expressed as

<mongodb:updateMany collectionName="atmosphericData">
    <mongodb:filter>
        { }
    </mongodb:filter>
    <mongodb:update>
        [{ 
            $set: { 
                temperature: {
                    $replaceAll: {
                        input: "$temperature",
                        find: "c",
                        replacement: "C"
                    }
                }
            }
        }]
    </mongodb:update>
</mongodb:updateMany>

Tests for both UpdateManyChange and the existing UpdateManyStatement are included.

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.

1 participant