Skip to content

Examples for Before/After Hooks on Create/Update/Delete, Soft Deletes, and Removing Methods #10

@MichaelrMentele

Description

@MichaelrMentele

VERY excited for this feature. Thank you for the examples!

One area I'm confused about is adding a side-effect to a model CUD action.

This could be replacing the delete action with a custom delete action or making sure some log is always written on table creation. Is this possible?

Also in the docs it says extensions could be used for soft-deletes and for removing deletes entirely would love examples of these two usecases as well.

Also, does this work so that if you override a method on a model you can ensure that nested creates on other models will work as well? For example, if I want to make sure there is no delete method on a model and remove that operation how can I prevent a nested delete on all the other models?

// extend model to disallow deletes

db.someModel.delete <- should be undefined

db.someOtherRelatedModel.update({
    where: ...,
    data: { someModel: { delete: true } }, // shouldn't work
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions