Extend before save and after save hooks and add a new property ctx.isNewInstance (or similar).
This new property will have one of the following values for Model.updateOrCreate:
before save:
- true when the data has not id and the method falls back to a regular create
- true/false when a non-atomic implementation is used
- undefined when an atomic implementation is used
after save:
- true when the connector reported that a record was created
- false when the connector reported that a record was updated
- undefined when the connector did not report anythin
A thing to figure out: how to handle atomic findOrCreate, as it may fire the before save hook even if the model already exists?
The original issue description
Does it make sense to have a created event on model? Currently we have changed, but that fires for any changes to the model.
Extend
before saveandafter savehooks and add a new propertyctx.isNewInstance(or similar).This new property will have one of the following values for
Model.updateOrCreate:before save:after save:A thing to figure out: how to handle atomic
findOrCreate, as it may fire thebefore savehook even if the model already exists?The original issue description
Does it make sense to have a
createdevent onmodel? Currently we havechanged, but that fires for any changes to the model.