Return `info.count` to the callback to indicate whether the model
instance was deleted or not. When Model's `settings.strictDelete`
is true, return 404 error when the model instance was not found.
Creates a new applyDefaultValues option on the Model constructor
defaulting to true, the current behaviour.
Updates the dao module to pass `{ applyDefaultValues: false }` to the
Model constructor during the updateOrCreate method when we assume an
update is happening.
- validateUpsert:true reports validation errors back to the callback
- validateUpsert:false does not call `isValid()` at all
- any other value report validation errors via `console.warn`
Fix the implementation of updateOrCreate (a.k.a. upsert) to validate
the model before calling the connector.
In order to preserve backwards compatibility, validation errors are
only logged via console.warn by default.
The correct behaviour, where validation errors fail the updateOrCreate
operation, can be enabled via new model setting "validateUpsert".
When the setting "persistUndefinedAsNull" is true,
the model will use `null` instead of `undefined` in
all property values.
- Known optional model properties are set to `null` when no value
was provided.
- When setting model properties, `undefined` is always converted
to `null`. This applies to both known (model-defined) properties
and additional (custom, dynamic) properties.
- The instance method `toObject()` converts `undefined` to `null` too.
Because `toJSON()` calls `toObject()` under the hood, the change
applies to `toJSON()` too.
Rename the second callback argument to `info` to make its purpose more
clear. Fix jsdoc comments, note that these comments are NOT shown
on http://apidocs.strongloop.com/.
ffcaa4e7 added a "data" argument to the callback function, which
shadowed the original data with the data returned by a connector.
Not all connectors are returning a data object though, in which case
the model instance ("this" object) is updated with wrong values.
This commit fixes the problem by renaming the second callback argument
to "unusedData".
"before save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
- true for all CREATE operations
- false for all UPDATE operations
- undefined for "prototype.save"
"after save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
- true after all CREATE operations
- false after all UPDATE operations
- undefined after "updateOrCreate" and "save"
Note: both "updateOrCreate" and "prototype.updateAttributes"
don't provide `ctx.instance` to "before save" hooks, therefore
`ctx.isNewInstance` it not provided either.