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

updateBulk Only Updating Last Record, Missing Updates for Other Records with the Same Key #1818

Open
tanchekwei opened this issue Oct 21, 2023 · 1 comment

Comments

@tanchekwei
Copy link

Below example updating as expected, Each item in the array contains both the content and done keys in its changes property.

await Messages.table.bulkUpdate([
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello!",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How can I",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How can I assist",
            "done": false
        }
    }
])

However, the code below only updates the last item in the array, which only updates { done: true }, causing the content changes in the other array items to be missing.

[
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How can I assist you",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How can I assist you today",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "content": "Hello! How can I assist you today?",
            "done": false
        }
    },
    {
        "key": "ffce6291-2fdf-4103-9960-1b208da10222",
        "changes": {
            "done": true
        }
    }
]

Is the behavior of updateBulk intentional when passing in array items with the same key?"

@dfahlander
Copy link
Collaborator

Interesting. I don't think that use case was anticipated when implementing it, but it would probably make sense to support it and apply all changes

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

No branches or pull requests

2 participants