Connect Loopback to various Data Sources
Go to file
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
.github Replicate new issue_template from loopback 2017-03-20 14:36:59 -04:00
docs Fix for issue #774 2015-11-24 16:50:41 +05:30
examples Upgrade eslint-config, fix new violations 2017-02-01 12:45:56 +01:00
intl Update error message 2017-03-16 11:02:08 -04:00
lib configurable model merge 2017-05-10 02:33:45 +02:00
support Fix manually 2016-08-22 19:20:12 -04:00
test configurable model merge 2017-05-10 02:33:45 +02:00
.editorconfig minor formatting issues (trailing spaces and such) and .editorconfig 2015-02-03 13:08:23 +03:00
.eslintignore Add eslint as "npm run lint" and "posttest" hook 2016-04-05 15:25:34 +02:00
.eslintrc Disable `strict` for a few files 2016-08-26 09:54:31 -04:00
.gitignore Add translation files 2016-09-20 13:34:44 -04:00
.gitmodules Remove unused support/ files 2016-04-05 15:25:34 +02:00
.npmignore kvao: implement key filter 2016-08-18 09:59:56 +02:00
.travis.yml Drop support for Node v0.10 and v0.12 2016-11-15 14:21:02 +01:00
CHANGES.md 3.6.1 2017-05-02 18:55:44 -04:00
CONTRIBUTING.md Add instructions for running the tests (#1330) 2017-04-17 11:14:00 -04:00
LICENSE Relicense as MIT only 2016-04-01 15:17:10 -07:00
NOTICE Add NOTICE 2015-07-18 19:44:46 -07:00
README.md Update README.md 2017-03-20 14:33:17 -04:00
docs.json docs: add DateString definition 2017-05-02 18:51:56 -04:00
index.js Fix manually 2016-08-22 19:20:12 -04:00
package.json 3.6.1 2017-05-02 18:55:44 -04:00

README.md

loopback-datasource-juggler

An ORM/ODM that provides a common set of interfaces for interacting with databases, REST APIs, and other types of data sources. It was originally forked from JugglingDB.

Supported versions

Current Long Term Support
3.x 2.x

Learn more about our LTS plan in the LoopBack documenation.

Usage

Install Juggler:

npm install loopback-datasource-juggler

Then install a connector:

npm install loopback-connector-mongodb // in this case, the mongodb connector

Documentation

See the LoopBack documentation.

For information on data source connectors, see Connecting models to data sources.