Skip to content

upsert method doesn't trigger any hooks for mysql adapter #461

@bahung1221

Description

@bahung1221

Hi,

I found that the upsert method won't trigger any hook if the adapter support updateOrCreate method (mysql in my case). I debugged and found the reason in below code:

if (this.schema.adapter.updateOrCreate) {

if (this.schema.adapter.updateOrCreate) {
        const inst = new Model(data);
        this.schema.callAdapter('updateOrCreate', Model.modelName, stripUndefined(inst.toObject(true)), (err, data) => {
            if (data) {
                return inst.reload(callback);
            }
            callback(err, null);
        });
    } else {
    ...
}

I think it should trigger save/update hooks like other methods,
If you need, i can create a PR for it,

Thank you very much for a nice job!

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