The name "query" creates incorrect assumption that hook handlers
may return the result of a query to bypass database access.
That is far from true, since this hook is called also by methods
like `deleteAll` or `updateAll` that don't perform any SELECT query.
The commit 1fd6eff1 (intent-based hooks) introduced a subtle regression
in `.save()` method where dynamic property setters were invoked twice.
This commit fixes the problem by moving pre-save data normalization
into `before save` callback.
This patch introduces a new API for "intent-based" hooks. These hooks
are not tied to a particular method (e.g. "find" or "update"). Instead,
they are triggered from all methods that execute a particular "intent".
The consumer API is very simple, there is a new method
Model.observe(name, observer), where the observer is function
observer(context, callback).
Observers are inherited by child models and it is possible to register
multiple observers for the same hook.
List of hooks:
- query
- before save
- after save
- after delete
2.14.0
* Remove console.log (Raymond Feng)
* Fix for #369 (Dallon Feldner)
* Fix virtual id get function. (Berkeley Martinez)
* Fix Model.prototype.inspect (Miroslav Bajtoš)
* Include property value in the error message (Miroslav Bajtoš)
* Update datasource.js (Rand McKinney)
* Change Model to BaseModel for clarity (Fabien Franzen)
* Don't coerce nested objects into Model instances (Fabien Franzen)
Return the raw object data when running on Node v0.11.14+
That way all `inspect` options are always preserved.
When running on older version:
- Honour the depth argument passed to the custom `inspect` function.
- Disable color output, becase there is now way how to detect whether
colors were enabled or disabled by the top-level caller.
When building a list of errors for `ValidationError.message`, include
the values of invalid properties too.
In order to keep the message reasonably short, the values are truncated
at approx 32 characters.
For queries, this is undesirable. It also affects
loopback-connector-mongodb's ability to perform nested queries (it
expects plain objects to work correctly, and to allow $elemMatch for
example).