loopback-datasource-juggler/lib
ebarault cfd3cdf535 Overall review of polymorphic relations
In #1298, the spec/doc for polymorphic relations was reviewed

**hasX relation**
- `type`: **hasMany**
- `as`: redefines **this** relation's name (optional)
- `model`: **modelTo**
- `polymorphic`:
  - typeOf `polymorphic` === `String`
    - matching **belongsTo** relation name
      - `foreignKey` is generated as `polymorphic + 'Id'`,
      - `discriminator` is generated as `polymorphic + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED** should display a warning,
            replaced by `selector`
    - `selector`: should match **belongsTo** relation name if the
                  latter is defined with {polymorphic: true}
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`:  A property of modelTo, representing the fk to
       modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`

---

**belongsTo relation**
- `type`: **belongsTo**
- `as`: redefines **this** relation's name (optional)
- `model`: **NOT EXPECTED**: should throw an error at
               relation validation
- `polymorphic`:
  - typeOf `polymorphic` === `Boolean`
      - `foreignKey` is generated as `relationName + 'Id'`,
      - `discriminator` is generated as `relationName + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED**: should display a warning,
            replaced by `selector`
    - `selector`:
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`: A property of modelTo, representing the fk to
                    modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`
2017-05-12 21:33:39 +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 Overall review of polymorphic relations 2017-05-12 21:33:39 +02: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 Overall review of polymorphic relations 2017-05-12 21:33:39 +02: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