Skip to content

Better support for model.save with partial setting of nested attributes #143

Open
@ambischof

Description

@ambischof

Lets say we have the following user:

bob = new MyModel({
   name: {
       first: 'bob',
       middle: 'bill',
       last: 'smith'
   }
})

if you do bob.set({name.first: "Bob"}) you'd get

{
   name: {
       first: 'Bob',
       middle: 'bill',
       last: 'smith'
   }
}

but if you try to do bob.save({'name.first': "Bob"}) you would get

{
   'name.first': 'Bob',
   name: {
       first: 'bob',
       middle: 'bill',
       last: 'smith'
   }
}

In order to avoid unintended consequences, there should be some mechanism to use save the same way you would use set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions