Commit Graph

2751 Commits

Author SHA1 Message Date
Sakib Hasan 7eca34552d Merge pull request #1392 from strongloop/fix/model-inheritance-test
Apply iteration on the model object
2017-05-30 21:58:56 -04:00
Sakib Hasan 3a10c77cbd Merge pull request #1393 from strongloop/fix/updateAttributes-cb
Fix updateAttributes cb
2017-05-30 21:28:00 -04:00
ssh24 ba1901b2a0 Fix updateAttributes cb
Allow pass through of the new data from the connector
Specifically for cloudant since updateAttributes changes the _rev
2017-05-29 15:32:32 -04:00
ssh24 e791e9006c Apply iteration on the model object 2017-05-26 18:49:54 -04:00
Rand McKinney 0a056adee4 Remove spurious extra options arg (#1390)
* Remove spurious extra options arg

* Remove space
2017-05-26 11:34:50 -07:00
Kevin Delisle 3630bb9ae4 Merge pull request #1387 from strongloop/ref/inclusion-docs
include: remove JSDoc refs to recursive calls
2017-05-24 19:41:06 -04:00
Kevin Delisle 1b625228b9 include: remove JSDoc refs to recursive calls 2017-05-24 17:10:45 -04:00
Sakib Hasan 0abfceebaa Merge pull request #1384 from strongloop/fix/model-inheritance-test
Fix count of properties
2017-05-24 10:27:54 -04:00
ssh24 825fa3171c Fix count of properties 2017-05-23 22:17:50 -04:00
Kevin Delisle 1fb4dd70e8 Merge pull request #1383 from strongloop/ref/hookable-docs
hooks: add JSDoc for .trigger
2017-05-23 19:54:32 -04:00
Kevin Delisle d058244594 hooks: add JSDoc for .trigger 2017-05-23 12:12:11 -04:00
Kevin Delisle a007c5a3fa Merge pull request #1379 from strongloop/ref/modelbuilder-apidocs
ModelBuilder API Doc Touchup
2017-05-23 10:38:57 -04:00
Kevin Delisle 117152d090 model-builder: JSDoc tidy-up 2017-05-23 10:31:38 -04:00
Raymond Feng b34b6e0ad4 3.9.0
* Return promise for batch create (Raymond Feng)
 * Use correct data on replace callback (ssh24)
2017-05-19 16:44:40 -07:00
Raymond Feng 492b644679 Merge pull request #1380 from strongloop/feature/fix-create-promise
Return promise for batch create
2017-05-19 18:43:35 -05:00
Raymond Feng 5a0b0270f3 Return promise for batch create 2017-05-19 16:16:52 -07:00
Kevin Delisle 790ccc3961 Merge pull request #1378 from strongloop/fix/use-correct-data-replaceCb
Use correct data on replace callback
2017-05-18 17:25:15 -04:00
ssh24 54f67dc3b0 Use correct data on replace callback
Previously, it would just pass the old data
Pass the new data as cloudant updates the _rev property on CRUD
2017-05-18 17:03:21 -04:00
Raymond Feng 22428cd58c 3.8.0
* fix assert, make the test case more clear (rashmihunt)
 * code review, better asserts (rashmihunt)
 * test case to exclude base props (rashmihunt)
 * handle excludeBaseProperties (rashmihunt)
2017-05-15 09:09:55 -07:00
Raymond Feng c41487a1d1 Merge pull request #1371 from strongloop/exclude_prop
Handle excludeBaseProperties
2017-05-15 11:06:27 -05:00
Kevin Delisle a4be61377a 3.7.0
* Remove unnecessary tests for adhocSort !== false (Tetsuo Seto)
 * Fix the test case to avoid duplicate userId (Tetsuo Seto)
 * Support include rework for C* connector (Tetsuo Seto)
 * Overall review of polymorphic relations (ebarault)
 * configurable model merge (ebarault)
 * Fix assertion errors (Loay)
 * Update modelbaseclass api docs (Loay)
 * Add caseInsensitive opt to validatesUniquenessOf (Bram Borggreve)
2017-05-15 11:20:28 -04:00
Tetsuo Seto 21cd515d4d Merge pull request #1362 from strongloop/include-rework-cassandra
Support include rework for C* connector
2017-05-15 08:09:11 -07:00
Tetsuo Seto ef08458e8d Remove unnecessary tests for adhocSort !== false 2017-05-15 03:04:09 -07:00
Tetsuo Seto aa3f5fa4f4 Fix the test case to avoid duplicate userId 2017-05-14 19:17:32 -07:00
Tetsuo Seto c07f46000d Support include rework for C* connector
- Remove supportNonPrimaryKeyIN
- Add C* Uuid in build call
- Implement smartMerge in scope.js
2017-05-12 22:43:21 -07:00
Kevin Delisle 4f335cb06f Merge pull request #1301 from strongloop/fix/shortcut-polymorphic-json-definition
honor polymorphic relations via JSON as in doc
2017-05-12 16:31:50 -04:00
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
rashmihunt 45bf569ec4 fix assert, make the test case more clear 2017-05-12 11:47:50 -07:00
rashmihunt fed0396d9e code review, better asserts 2017-05-11 09:59:39 -07:00
rashmihunt 5aee1fe17e test case to exclude base props 2017-05-10 12:03:42 -07:00
rashmihunt 52f8fb3416 handle excludeBaseProperties 2017-05-10 12:03:42 -07:00
Kevin Delisle d375d61519 Merge pull request #1289 from strongloop/fix/preventRelationsMerge
review model settings merge/inheritance policy (util/mergeSettings() ) : relations, acls, ...
2017-05-10 12:56:23 -04:00
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
Loay e3ce44a286 Merge pull request #818 from fullcube/fullcube/validatesUniquenessOf-case-insensitive
Fullcube/validates uniqueness of case insensitive
2017-05-05 10:41:42 -04:00
Loay b39ee050f3 Merge pull request #1363 from strongloop/fix-1304
Fix error assertion
2017-05-04 11:18:19 -04:00
Loay 87dd44dd59 Fix assertion errors 2017-05-04 10:38:06 -04:00
Loay c80daae5a1 Merge pull request #1366 from strongloop/api-ModelBase
Update ModelBaseClass api docs
2017-05-03 22:31:56 -04:00
Loay 84b55d8160 Update modelbaseclass api docs 2017-05-03 21:03:36 -04:00
Kevin Delisle 6b43378396 3.6.1
* docs: add DateString definition (Kevin Delisle)
2017-05-02 18:55:44 -04:00
Kevin Delisle 53fd8d79f8 Merge pull request #1365 from strongloop/docs/datestring
docs: add DateString definition
2017-05-02 18:55:12 -04:00
Kevin Delisle 0e955b0f35 docs: add DateString definition 2017-05-02 18:51:56 -04:00
Kevin Delisle 6bbad5e9a9 3.6.0
* create sequence for nosql id (#1354) (Janny)
 * Fix order of query results (Loay)
 * Add DateString type (Kevin Delisle)
 * datatype.test: use predefined date (Kevin Delisle)
 * Update api documents (Loay)
 * Datasource documentation tune-up (Kevin Delisle)
 * Added unit tests specific to DateType where null (#1349) (Andrew McDonnell)
 * Fix/geo null (#1334) (paulussup)
 * replace exception thrown for invalid dates (Diana Lau)
 * Revert PR #1326 (#1336) (Sakib Hasan)
 * Make lib peerDepend on loopback-connector (#1326) (Russ Tyndall)
 * Add test case using updateAttributes (Loay)
 * Fix forceId bug for updateOrCreate (Loay)
 * Fix typo in description (jannyHou)
 * Fix relations test case (loay)
2017-05-02 18:34:11 -04:00
Kevin Delisle 156b638518 Merge pull request #1356 from strongloop/datetype-allow-strings
Add DateString type
2017-05-02 14:48:50 -04:00
Janny 5d10c72664 create sequence for nosql id (#1354)
* create sequence for nosql id
2017-05-02 13:35:57 -04:00
Bram Borggreve c3629633de
Add caseInsensitive opt to validatesUniquenessOf 2017-05-01 17:26:16 -05:00
Kevin Delisle 6342a0387f Merge pull request #1364 from strongloop/query-order
Fix order of query results
2017-05-01 17:21:00 -04:00
Loay 6cfdcc0128 Fix order of query results 2017-05-01 16:10:55 -04:00
Kevin Delisle 5e80837424 Add DateString type
New type that preserves string input as a string, but ensures that
the string is a valid Date.

Additionally, provides a .toDate function to provide the Date
object representation of the string.
2017-05-01 12:28:59 -04:00
Kevin Delisle 97f243f347 Merge pull request #1360 from strongloop/datatype-test/use-predefined-date
datatype.test: use predefined date
2017-04-28 16:42:10 -04:00
Kevin Delisle 8e97385a8f datatype.test: use predefined date
Some databases are storing the value in UTC (not ISO) format,
and truncating the values. Even though this is technically
unavoidable, it does fail strict string equality.
2017-04-28 15:40:19 -04:00