Signed-off-by: Clark Wang <clark.wangs@gmail.com>
remove undefined for creating data in findOrCreate
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
getLastGeneratedUid instead of force an id
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2.16.0
* Return 400 when client provides an incorrect value (Pradnya Baviskar)
* Relax "id" checks in test/manipulation.test.js (Miroslav Bajtoš)
* Fix typo (Raymond Feng)
* test: undefined property values are preserved (Miroslav Bajtoš)
* Remove undefined properties for create (Raymond Feng)
* Update to `should` to the latest version 4.6.3 (Miroslav Bajtoš)
* Relax the id equality test for mongodb object ids (Raymond Feng)
So hasOne#create could take advantage from optimized findOrCreate,
which can avoid multiple creation among concurrent requests.
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2.15.0
* Fix id type issue for update (Raymond Feng)
* Rename hook "query" to "access" (Miroslav Bajtoš)
* Implement intent hook `before delete` (Miroslav Bajtoš)
* Remove redundant `.toObject()` call from `upsert` (Miroslav Bajtoš)
* Fix regression in `.save()` from 1fd6eff1 (Miroslav Bajtoš)
* Fix hasOne remoting (Raymond Feng)
* Make sure batch create calls back with correct data (Raymond Feng)
* Intent-based hooks for persistence (Miroslav Bajtoš)
* ModelBaseClass: implement async observe/notify (Miroslav Bajtoš)
* Upgrade `should` to the latest 1.x version (Miroslav Bajtoš)
* Fixed nullCheck in validations to correct behavior when dealing with undefined attributes (James Billingham)
* Supply target to applyProperties function (Fabien Franzen)
* fix id property for composite ids (Clark Wang)
* fix id properties should sort by its index (Clark Wang)
* Fixed typos and logic for protected properties (Christian Enevoldsen)
* adds support for protected properties. (Christian Enevoldsen)
* support embeds data for belongsTo relation Signed-off-by: Clark Wang <clark.wangs@gmail.com> (Clark Wang)
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