Commit Graph

2360 Commits

Author SHA1 Message Date
Amir Jafarian a96a8f379a Remove unused variables in model.js
Backport loopback-datasource-juggler#1010
2016-07-23 16:56:16 -04:00
Amir-61 fa65094583 Merge pull request #1012 from strongloop/Add_test_for_updateOrCreate_2.x
Add test for updateOrCreate[2.x]
2016-07-23 15:01:50 -04:00
Amir-61 1615caca9d Merge pull request #1013 from strongloop/Declare_definition_2.x
Declare definition[2.x]
2016-07-23 13:19:24 -04:00
Amir Jafarian 6efd00698b Add test for updateOrCreate
* Add test for updateOrCreate when id is not autogenerated Id
Backport loopback-datasource-juggler#989
2016-07-23 11:25:38 -04:00
Amir Jafarian 69cc091ef4 Declare `definition`
* Declare `definition` in `BelongsTo.prototype.destroy`
Backport loopback-datasource-juggler#1009
2016-07-23 11:24:34 -04:00
Supasate Choochaisri f1a70094fa Add test to catch invalid date property
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
See https://github.com/strongloop/loopback-datasource-juggler/pull/1000
2016-07-15 10:47:44 -07:00
Miroslav Bajtoš 4e5ae72eef 2.47.0
* Ensure stable order of items in DAO.find() (Miroslav Bajtoš)
 * give options to validators #984 (RobinBiondi)
 * Update datasource.js (Amir Jafarian)
 * Give warning if PK is changed in hooks (Amir Jafarian)
 * Persist changes on parent for embedsOne (Dimitris Halatsis)
2016-07-14 14:02:12 +02:00
Miroslav Bajtoš 8173a4306c Merge pull request #999 from strongloop/fix/order-in-find-2.x
Ensure stable order of items in DAO.find() [2.x]
2016-07-14 14:01:14 +02:00
Miroslav Bajtoš ebcb5a0546 Ensure stable order of items in DAO.find()
When post-processing result of find operation, use "async.map"
instead of "async.each + array.push" to ensure the order of items
is preserved.
2016-07-13 15:25:34 +02:00
Raymond Feng 6736d72b98 Merge pull request #986 from robinbiondi/postgresConcurency
Fix #984 Give request options(ex: transactions) to validators
2016-06-24 14:42:50 -07:00
RobinBiondi 35f14c38dc give options to validators #984 2016-06-24 22:04:35 +02:00
Amir-61 48e949e996 Merge pull request #980 from strongloop/updata_datasource_2.x
Updata datasource.js
2016-06-17 13:42:22 -04:00
Amir Jafarian 5f8e28a6c0 Update datasource.js
Return a real `Error` message for the default `ping()` method.
2016-06-17 11:36:13 -04:00
Amir-61 892c228797 Merge pull request #968 from strongloop/warning_for_changing_PK_in_hooks_2.x
Give warning if PK is changed in hooks
2016-06-08 18:13:55 -04:00
Amir Jafarian 26718c733a Give warning if PK is changed in hooks
* Give warning if PK is changed in `before save` and `loaded`
 operation hooks for replaceById
2016-06-08 15:54:22 -04:00
Miroslav Bajtoš bfbdd15f1d Merge pull request #949 from mitsos1os/2.x
Persist changes on parent for embedsOne

Close #949
2016-06-07 17:23:14 +02:00
Dimitris Halatsis af8cf19242 Persist changes on parent for embedsOne
Allow direct save of changes on embedded model to be persisted on
parent document.

    Person.embedsOne(Address);
    Person.findById(someId)
      .then(function(p){
        var address = p.addressItem();
        address.street = 'new street'
        // This will now persist changes on parent document
        return address.save();
      })
2016-06-07 17:09:34 +02:00
Raymond Feng baef033115 2.46.1
* fix (Miroslav Bajtoš)
 * Retun err for UPSERT if the connector returns err (Amir Jafarian)
 * Fix error message (Amir Jafarian)
 * Add test's description (Amir Jafarian)
 * ModelBuilder: add new setting strictEmbeddedModels (Dimitris Halatsis)
 * Fix incompatibility between different connectors PR#938 (Amir Jafarian)
 * travis: add v4, v6, drop io.js (Miroslav Bajtoš)
 * Backport ESLint from master (Simon Ho)
 * Set ESLint as devdep (Simon Ho)
 * Use mocha instead of Makefile for testing (Simon Ho)
 * Implement operation hooks for EmbedsMany methods (Miroslav Bajtoš)
 * Implement operation hooks for EmbedsOne methods (Miroslav Bajtoš)
 * eslint config 2.0 + remove extra empty lines (Miroslav Bajtoš)
 * Fix eslint errors in memory connector (Miroslav Bajtoš)
 * Run `eslint --fix` with config from master (Miroslav Bajtoš)
 * Test coverages for hashed password (Amir Jafarian)
 * Fix `forceId` check for `replaceByIds` PR#896 (Amir Jafarian)
 * test: extract hook-monitor helper (Miroslav Bajtoš)
 * test: extract uid-generator helper (Miroslav Bajtoš)
 * test: extract context-test-helpers (Miroslav Bajtoš)
 * Define `patch` aliases (Amir Jafarian)
2016-06-03 14:53:00 -07:00
Amir-61 be17bedcc5 Merge pull request #962 from strongloop/fix2x
fix
2016-06-03 17:46:10 -04:00
Miroslav Bajtoš 9bf60e0d74 fix 2016-06-03 16:29:39 -04:00
Amir-61 534a0e5892 Merge pull request #957 from strongloop/upsert_err
Retun err for UPSERT if the connector returns err
2016-06-02 08:37:02 -04:00
Amir Jafarian dddf0ee09a Retun err for UPSERT if the connector returns err 2016-06-02 08:31:13 -04:00
Amir-61 7aa9cb357d Merge pull request #959 from strongloop/fix_err_msg
Fix error message
2016-06-01 21:00:26 -04:00
Amir-61 2e11dbfe35 Merge pull request #958 from strongloop/Add_test_desc
Add test's description
2016-06-01 20:29:46 -04:00
Amir Jafarian c093648525 Fix error message
* Fix error message when PK is changed in `replaceById`
2016-06-01 16:26:41 -04:00
Amir Jafarian 05ea5467cd Add test's description 2016-06-01 16:05:56 -04:00
Dimitris Halatsis 39907c6421 ModelBuilder: add new setting strictEmbeddedModels
The setting controls the strict mode used for embedded property types,
for example the type of "address" property in this model definition:

    modelBuilder.define('TestEmbedded', {
      name: 'string',
      address: {
        street: 'string',
      },
    });

[back-port of #955]
2016-06-01 13:42:55 +02:00
Amir Jafarian 0d5cff5a0a Fix incompatibility between different connectors PR#938
* Fix incompatibility for replace methods between different connectors.
2016-05-28 09:12:30 -04:00
Miroslav Bajtoš a9f69bcbc6 travis: add v4, v6, drop io.js
[back-port of #943]
2016-05-23 11:24:28 +02:00
Miroslav Bajtoš a6f499703e Merge pull request #928 from strongloop/backport/eslint
Backport eslint from master
2016-05-23 11:03:32 +02:00
Simon Ho 65d6d6a508 Backport ESLint from master 2016-05-20 17:35:23 +02:00
Simon Ho ee6c0ad461 Set ESLint as devdep 2016-05-10 13:37:44 -07:00
Simon Ho 4c7d862cee Use mocha instead of Makefile for testing 2016-05-10 12:06:34 -07:00
Miroslav Bajtoš bec9142100 Implement operation hooks for EmbedsMany methods
create() triggers
 - before save
 - after save

updateById() triggers
 - before save
 - after save

destroy() triggers
 - before delete
 - after delete

The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.

Limitations:

 - `before save` & `after save` hooks don't provide `ctx.isNewInstance`
 - async validations are not supported yet
 - `persist` and `loaded` hooks are not triggered at all

 - `before delete` hook does not provide `ctx.where` property and
    it's not possible to change the outcome of `destroy()` using this
    hook. Note that regular DAO does support this.

 - updating embedded instances triggers update of the parent (owning)
   model, which is correct and expected. However, the context provided
   by `before save` and `after save` hooks on the parent model is sort of
   arbitrary and may include wrong/extra data. The same probably applies
   to the scenario when deleting embedded instances triggers update of
   the parent model.

[back-port of #911]
2016-04-28 10:15:14 +02:00
Miroslav Bajtoš f65b542dab Implement operation hooks for EmbedsOne methods
create() triggers
 - before save
 - after save

udpate() triggers
 - before save
 - after save

destroy() triggers
 - before delete
 - after delete

The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.

[back-port of #904]
2016-04-20 10:30:56 +02:00
Miroslav Bajtoš 289eac7565 eslint config 2.0 + remove extra empty lines
Upgrade eslint-config-loopback to ^2.0.0.

Remove extra empty lines to make `npm run lint` pass again.

[back-port of #909]
2016-04-19 17:06:04 +02:00
Miroslav Bajtoš feca7481e9 Merge pull request #905 from strongloop/eslint-autofix-2x
Eslint autofix for 2.x
2016-04-18 16:41:28 +02:00
Miroslav Bajtoš 4000b70e38 Fix eslint errors in memory connector 2016-04-18 16:00:04 +02:00
Miroslav Bajtoš a5187765f6 Run `eslint --fix` with config from master 2016-04-18 16:00:04 +02:00
Amir Jafarian fd1afdf6e6 Test coverages for hashed password
* Test coverages for hashed password for replaceAttributes
* Test coverages for hashed password for updateAttribute
2016-04-15 12:58:36 -04:00
Amir Jafarian 1eeacd0255 Fix `forceId` check for `replaceByIds` PR#896 2016-04-14 17:59:30 -04:00
Miroslav Bajtoš 0de6dd72a4 Merge pull request #902 from strongloop/refactor/context-test-helpers
test: extract helpers used in tests for operation hooks
2016-04-13 15:16:26 +02:00
Miroslav Bajtoš 7d7662bfef test: extract hook-monitor helper 2016-04-13 15:15:55 +02:00
Miroslav Bajtoš 90f04181a4 test: extract uid-generator helper 2016-04-13 15:15:55 +02:00
Miroslav Bajtoš 09ad9e4711 test: extract context-test-helpers 2016-04-13 15:15:53 +02:00
Amir Jafarian 7773963b62 Define `patch` aliases
*Define `patchOrCreate` as an alias for `updateOrCreate`
*Define `PatchAttributes` as an alias for `updateAttributes`
2016-04-12 16:32:17 -04:00
Miroslav Bajtoš 7eee0afb52 2.46.0
* Insert copyright headers (Miroslav Bajtoš)
 * Relicense as MIT only (Miroslav Bajtoš)
 * Fix Mongo compatibility issue (Amir Jafarian)
 * Add automigrate to setup tables for replace test cases (Amir Jafarian)
 * Remove next tag (2.x) (Amir Jafarian)
 * Allow test folder to be published (Amir Jafarian)
 * Fix tests for mysql (Amir Jafarian)
 * Add forgotten unit test (Miroslav Bajtoš)
 * Improve error message on connector init error (Miroslav Bajtoš)
 * Update describe-operation-hooks (Miroslav Bajtoš)
 * Fix missing connector error msg for db2, cloudant for 2.x (Candy)
 * Implementtaion of replace (Amir Jafarian)
2016-04-07 09:12:48 +02:00
Miroslav Bajtoš fbd8b67766 Merge pull request #891 from strongloop/copyright-2.x
Relicense as MIT only
2016-04-07 09:11:04 +02:00
Miroslav Bajtoš 093a69328c Insert copyright headers 2016-04-06 16:51:49 +02:00
Miroslav Bajtoš 216a537a23 Relicense as MIT only 2016-04-06 16:50:02 +02:00