Skip to content

Update models with multiple values at the same time #44

@Artmann

Description

@Artmann

When you have an object with data that you want to update your model with, like when you have submitted a form, it's very cumbersome to have to assign each value to the model.

Example

/// Instead of

const data = { name: 'Chair 1', price: 42.00 }
const product = Product.find(id)

product.name = data.name
product.price = data.price

await product.save()

// Do

const data = { name: 'Chair 1', price: 42.00 }
const product = Product.find(id)

await product.update(data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions