Introduce the new property atomicUpsertWithWhere for
connector that implement specific method.
See https://github.com/strongloop/loopback-connector-mongodb/pull/563
for mongodb implementation.
Signed-off-by: Matteo Padovano <mrbatista@users.noreply.github.com>
Before this change, when both the PK value (`id`) and the `data` object
were provided as plain-data values (e.g. as received in a JSON request),
and the connector was using a complex PK type (e.g. `ObjectID`
in MongoDB), then `replaceById` operation was printing confusing
warnings:
WARNING: id property cannot be changed from 5d39775a59f5f541513c5e05
to 5d39775a59f5f541513c5e05 for model:Post
in 'before save' operation hook
WARNING: id property cannot be changed from 5d39775a59f5f541513c5e05
to 5d39775a59f5f541513c5e05 for model:Post
in 'loaded' operation hook
This commit fixes the problem by applying the same type coercion on the
PK value (`id`) as has been applied by the model constructor on the PK
property (`data.id`).
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Before this change, when a property was configured with a default value
at LoopBack side and the database was returned a record with a missing
value for such property, then we would supply use the configured
default.
This behavior is problematic for reasons explained in #1692.
In this commit, we are fixing DAO operations like `find` and
`findOrCreate` so that they do NOT apply default property values on
data returned by the database (connector).
Please note that most of the other CRUD methods were already not
applying default values on database data as long as the connector
provided native implementation of the operation.
The new version of our config enabled function-paren-newline rule,
this commit fixes the codebase to use more consistent handling
of newlines when calling functions.
Some connector, like arangodb, not support id as Number.
When `forceId` is set to true and id is set `Model.isValid`
report error and the field id is not coerced.