Rework the code building model constructors to leverage `Function` class
and dynamically emit a constructor function named after the model.
Before this change, all model classes were called "ModelConstructor",
which made debugging difficult.
After this change, a model class for model "User" is called "User.
Because not all valid model names are also valid JavaScript identifiers,
we implement a simple sanitization technique (replacing characters like
"-", "." and ":" with underscore "_") and fall back to legacy
"ModelConstructor" if the model name is still not a valid JS identifier.
The uniq function does currently not work when the database is mongodb.
In the case of mongodb, the function will receive an array of bson
object of bson type ObjectID. The indexOf function will return a
different index, even if the mongodb ID is the same, as it is wrapped
in the ObjectID. This commit first transforms any ObjectID in the array
to a string representation. We can then use indexOf to check for
uniqueness.
* Add a better way to handle transactions (Jürg Lehni)
* validations: use new regex per evaluation (#1479) (Joost de Bruijn)
* Transaction: Bind timeout to tx instance (#1484) (Jürg Lehni)
* CODEOWNERS: add lehni (#1483) (Miroslav Bajtoš)
* Add node8 support for travis (loay)
* Add nyc coverage, report data to coveralls.io (Miroslav Bajtoš)
* Update translations from TVT (Allen Boone)
* Add test coverage for hasAndBelongsToMany (loay)
* package: use qs@6.5.0 (#1471) (Kevin Delisle)
* updateOnly, forceId changes
* support getUpdateOnlyProperties
* fixup! fix updateOrCreate in forceId mode
The contract of `updateOrCreate` is expecting a full object instance
to be passed to the callback.
The current implementation was creating an empty instance and
calling updateAttributes under the hood. As a result, the callback
was called with the attributes being updated only.
In order to preserve existing behaviour, we have to always build
a full initial instance by calling `findById`.
See the following discussion for more context:
https://github.com/strongloop/loopback-datasource-juggler/issues/966
* fixup! fix tests of upsert validation
* move forceId to model-builder
* remove TODO comment
* revert refactoring and test fixes
* Remove duplicate test
* change testcase names
* change to ModeClass.settingse
* forceId setup from datasource to model-builder
* fix inheritance of auto-generated forceId
* Fixed failing tests for auto change
* fixed a comment