loopback-datasource-juggler/lib
ebarault 79068d142b configurable model merge
The PR superseeds the existing deepMerge algorithm used to merge
settings of parent and child models with a new algorithm that allows
to specify the way each setting is merged or mixed-in.

This configuration of this algorithm uses a merge policy specification.
The `getMergePolicy()` helper of BaseModelClass can be used to ease
model merge configuration.

Next is presented the expected merge behaviour for each option.
NOTE: This applies to top-level settings properties

- Any
  - `{replace: true}` (default): child replaces the value from parent
  - assignin `null` on child setting deletes the inherited setting

- Arrays
  - `{replace: false}`: unique elements of parent and child cumulate
  - `{rank: true}` adds the model inheritance rank to array
    elements of type Object {} as internal property `__rank`

- Object {}:
  - `{replace: false}`: deep merges parent and child objects
  - `{patch: true}`: child replaces inner properties from parent

The recommended merge policy is returned by getMergePolicy()
when calling the method with option `{configureModelMerge: true}`.

The legacy built-in merge policy is returned by `getMergePolicy()`
when avoiding option `configureModelMerge`.
NOTE: it also delivers ACLs ranking in addition to the legacy
behaviour as well as fixes for settings `description` and `relations`

`getMergePolicy()` can be customized using model's setting
`configureModelMerge` as follows:
```
{
  // ..
  options: {
    configureModelMerge: {
      // merge options
    }
  }
  // ..
}
```

`getMergePolicy()` method can also be extended programmatically as
follows:
```
myModel.getMergePolicy = function(options) {
  const origin = myModel.base.getMergePolicy(options);
  return Object.assign({}, origin, {
    // new/overriding options
  });
};
```
2017-05-10 02:33:45 +02:00
..
connectors Fix forceId bug for updateOrCreate 2017-04-18 13:14:35 -04:00
kvao Refactor flush to deleteAll 2017-01-09 14:53:34 -08:00
browser.depd.js Fix manually 2016-08-22 19:20:12 -04:00
dao.js Fix assertion errors 2017-05-04 10:38:06 -04:00
datasource.js Update api documents 2017-04-27 16:28:43 -04:00
date-string.js Add DateString type 2017-05-01 12:28:59 -04:00
geo.js Fix/geo null (#1334) 2017-04-24 19:28:11 -04:00
hooks.js Fix manually 2016-08-22 19:20:12 -04:00
include.js Fixes #1275. `Include` filter transforms fields property into array. (#1276) 2017-03-22 10:03:36 -04:00
include_utils.js Fix manually 2016-08-22 19:20:12 -04:00
introspection.js Fix manually 2016-08-22 19:20:12 -04:00
jutil.js Fix manually 2016-08-22 19:20:12 -04:00
list.js Upgrade eslint-config, fix new violations 2017-02-01 12:45:56 +01:00
mixins.js Fix manually 2016-08-22 19:20:12 -04:00
model-builder.js configurable model merge 2017-05-10 02:33:45 +02:00
model-definition.js Fix model def column name method (#1224) 2017-04-05 15:12:27 -04:00
model.js configurable model merge 2017-05-10 02:33:45 +02:00
observer.js Fix manually 2016-08-22 19:20:12 -04:00
relation-definition.js Custom Table Names on rels (#1303) 2017-04-05 12:42:21 -04:00
relations.js Fix manually 2016-08-22 19:20:12 -04:00
scope.js Fix - `_targetClass` on scope function (#1280) 2017-03-22 17:06:36 -04:00
transaction.js Upgrade dependencies to remove npm install warnings 2017-01-17 09:45:51 -08:00
types.js Add DateString type 2017-05-01 12:28:59 -04:00
utils.js configurable model merge 2017-05-10 02:33:45 +02:00
validations.js Add caseInsensitive opt to validatesUniquenessOf 2017-05-01 17:26:16 -05:00