Commit Graph

22 Commits

Author SHA1 Message Date
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
Dimitris 2bfc769c4d Using a filter with exclusion of a non existent property, removes an existing one (#1257)
* #fixes 1256

* Added missing check for returned error

* Fixed test to check proper fields in each doc
2017-03-20 19:18:48 -04:00
Miroslav Bajtoš 454bf93aaf Upgrade eslint-config to 7.x
Also upgrade eslint itself to 3.x.
2017-01-06 13:33:54 +01:00
Siddhi Pai 3baa61590e Fix block padding
* Remove test/.eslintrc
* run eslint . --fix
2016-12-13 16:05:50 -08:00
Amir Jafarian aec678d252 Fix manually 2016-08-22 19:20:12 -04:00
Amir Jafarian aa6d28268b Auto-update by eslint --fix 2016-08-22 15:12:25 -04:00
Miroslav Bajtoš 39e04a1756 eslint --fix 2016-04-05 15:25:34 +02:00
Ryan Graham c467b43c38 Insert copyright headers 2016-04-04 18:14:03 -07:00
Ryan Schumacher 94c3f9a432 Ability to define normalization of undefined query
Add datasource and model setting `normalizeUndefinedInQuery`
to determine how it will handle undefined values. Options:

- nullify : converts undefined to null
- throw : throw an error on undefined value
- ignore : strip the key where undefined value is found

The default operation is to strip the key.
2015-10-07 09:26:09 -07:00
Simon Ho fee103d9d7 Remove test for unused utility function 2015-07-28 17:45:38 -07:00
Simon Ho b8f1598723 Add support for regex operator 2015-07-27 15:11:53 -07:00
Raymond Feng 493d98f66b Dedupe ids args of inq for include 2015-05-29 10:50:37 -07:00
Raymond Feng 966bb56c31 Enhance fieldsToArray to consider strict mode 2015-05-19 22:32:03 -07:00
ningsuhen 9a7f13ff0f Add support for merging include filters 2015-04-25 01:59:39 +05:30
Fabien Franzen 3e300c1f35 Add strict flag to sortObjectsByIds
When true, any object not in the ids will be discarded and a subset
will be returned.
2014-08-15 19:47:12 +02:00
Fabien Franzen 9f1c5d9c37 Moved DataAccessObject.sortByIds to utils.js 2014-08-15 19:39:58 +02:00
Raymond Feng 2b8c1ebaee Reformat the code 2014-01-24 09:09:53 -08:00
Raymond Feng aabe5fb1c4 Fix a bug in merging ACLs 2013-12-16 17:14:56 -08:00
Raymond Feng d0055d8591 Fix removeUndefined to bypass non-plain objects
traverse.map() transform custom objects such as Date or ObjectID into
plain objects and it breaks the BSON serialization
2013-10-29 22:16:43 -07:00
Raymond Feng f3011216b5 Support datasource/connector configuration using URL string 2013-10-25 16:18:02 -07:00
Raymond Feng 9ec9f654c7 Remove undefined values from the query object 2013-10-11 11:50:00 -07:00
Ritchie Martori d4ca20c01a Add filter.fields support to dao and memory connector 2013-07-16 17:53:52 -07:00