Allow direct save of changes on embedded model to be persisted on
parent document.
Person.embedsOne(Address);
Person.findById(someId)
.then(function(p){
var address = p.addressItem();
address.street = 'new street'
// This will now persist changes on parent document
return address.save();
})
[forward-port of #949]
The setting controls the strict mode used for embedded property types,
for example the type of "address" property in this model definition:
modelBuilder.define('TestEmbedded', {
name: 'string',
address: {
street: 'string',
},
});
It was previously completely undocumented. There are additional methods that add promises but I figure accurately documenting some is better than none. :)
Simplify DataAccessObject.create() and stop returning the
instance/array of instances. Users should always use callback (or
returned promise) to get the instance(s) created.
create() triggers
- before save
- after save
updateById() triggers
- before save
- after save
destroy() triggers
- before delete
- after delete
The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.
Limitations:
- `before save` & `after save` hooks don't provide `ctx.isNewInstance`
- async validations are not supported yet
- `persist` and `loaded` hooks are not triggered at all
- `before delete` hook does not provide `ctx.where` property and
it's not possible to change the outcome of `destroy()` using this
hook. Note that regular DAO does support this.
- updating embedded instances triggers update of the parent (owning)
model, which is correct and expected. However, the context provided
by `before save` and `after save` hooks on the parent model is sort of
arbitrary and may include wrong/extra data. The same probably applies
to the scenario when deleting embedded instances triggers update of
the parent model.
create() triggers
- before save
- after save
udpate() triggers
- before save
- after save
destroy() triggers
- before delete
- after delete
The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.
* Partition by foreign key for pagination (Raymond Feng)
* Fix style errors (Raymond Feng)
* fix remaining eslint issues (Miroslav Bajtoš)
* eslint --fix (Miroslav Bajtoš)
* Add eslint as "npm run lint" and "posttest" hook (Miroslav Bajtoš)
* Remove unused support/ files (Miroslav Bajtoš)
* Insert copyright headers (Ryan Graham)
* Relicense as MIT only (Ryan Graham)
* Fix Mongo compatibility issue (Amir Jafarian)
* Add automigrate to setup tables for replace test cases (Amir Jafarian)
* Allow test folder to be published (Amir Jafarian)
* support custom field settings under the connector's namespace (bitmage)
* Update error message for missing connector (gunjpan)
* Fix tests for mysql (Amir Jafarian)
* Add forgotten unit test (Miroslav Bajtoš)
* fix nin support for in memory datasource (Horia Radu)
* Improve error message on connector init error (Miroslav Bajtoš)
* discoverSchemas returns an error when modelName is not found, discoverSchema forwards that error and does not hang when no columns, no errors are returned (bitmage)