Commit Graph

2093 Commits

Author SHA1 Message Date
Simon Ho 04f35b31b4 Memory connector returns updated records count
The memory connector now includes the number of updated items in its callback
when updating records.
2015-03-19 15:40:14 -07:00
Raymond Feng a8d8556dcc Merge pull request #499 from clarkorz/fix/merge-mixins
fix #429 Multiple Models can't mixin same class
2015-03-19 13:21:22 -07:00
Miroslav Bajtoš e83edf8555 Merge pull request #511 from strongloop/feature/report-count-of-deleted-instances
deleteAll returns number of deleted records
2015-03-19 19:01:30 +01:00
Miroslav Bajtoš ffcaa4e76e Add ctx.isNewInstance for "save" hooks
"before save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
 - true for all CREATE operations
 - false for all UPDATE operations
 - undefined for "prototype.save"

"after save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
 - true after all CREATE operations
 - false after all UPDATE operations
 - undefined after "updateOrCreate" and "save"

Note: both "updateOrCreate" and "prototype.updateAttributes"
don't provide `ctx.instance` to "before save" hooks, therefore
`ctx.isNewInstance` it not provided either.
2015-03-19 18:05:24 +01:00
Miroslav Bajtoš d731252941 deleteAll returns number of deleted records
The number is returned as `data.ctx` to `cb(null, data)`.
2015-03-19 17:54:22 +01:00
Miroslav Bajtoš ae3dc3cec2 Merge pull request #510 from strongloop/fix/duplicate-create
Reject CREATE with a duplicate id
2015-03-19 17:37:01 +01:00
Fabien Franzen 8f88a42395 Enable custom methods on singular relations 2015-03-19 17:13:18 +01:00
Raymond Feng 579895d1b3 Merge pull request #513 from strongloop/feature/fix-issue-512
Use the correct way to iterate over an array
2015-03-18 08:22:06 -07:00
Raymond Feng cd1d815936 Use the correct way to iterate over an array
See https://github.com/strongloop/loopback-datasource-juggler/issues/512
2015-03-18 08:21:32 -07:00
Raymond Feng 01fb5db550 Merge pull request #509 from dbarbeau/master
Enable "between" filter for memory db connector
2015-03-16 10:41:38 -07:00
Miroslav Bajtoš 6f11c2d717 DAO: Fix updateOrCreate to set persisted:true
Before this commit, the following code would not work:

    Change.updateOrCreate({...}, function(err, ch) {
      // somewhere later, modify "ch" and save the changes
      ch.save(cb);
    });
2015-03-16 18:26:42 +01:00
Miroslav Bajtoš 902772f1af Reject CREATE with a duplicate id
Modify the memory connector to reject requests to create a record
with a duplicate id.

Add a unit-test to verify this behaviour across all connectors.
2015-03-16 18:26:42 +01:00
Daniel B. Vasquez 3de94cb9bd add tests for between in memory connector 2015-03-16 18:26:33 +01:00
Raymond Feng 53d694b429 2.21.0
* Fix the test case so that at least one property is to be changed (Raymond Feng)

 * Make sure id properties cannot be changed (Raymond Feng)
2015-03-16 09:54:06 -07:00
Raymond Feng eb9a8f59e5 Merge pull request #508 from strongloop/feature/fix-update-attrs
Make sure id properties cannot be changed
2015-03-16 09:53:10 -07:00
Raymond Feng f91399a307 Fix the test case so that at least one property is to be changed 2015-03-16 09:26:03 -07:00
Raymond Feng 04348a1168 Make sure id properties cannot be changed 2015-03-16 09:25:38 -07:00
Daniel B. Vasquez 9aeaa37b1c enable between filter for memory db connector 2015-03-16 11:21:04 +01:00
Raymond Feng 7dc0fcd26f 2.20.0
* Remove trailing spaces. (Miroslav Bajtoš)

 * Improve instance-level operation hooks (Fabien Franzen)

 * Fix the test case (Raymond Feng)

 * fix foreign key dataType bug (didikeke)

 * Reformat notifyObserversOf context argument (Fabien Franzen)

 * Implement operation hooks' context (Fabien Franzen)

 * Allow submodel to hide base properties (Raymond Feng)
2015-03-12 10:22:05 -07:00
0angelic0 befe30f14a Add abilities to remove and clear observers - Operation Hooks. 2015-03-11 18:08:35 +07:00
Miroslav Bajtoš 274a5c778a Remove trailing spaces. 2015-03-11 09:39:16 +01:00
Miroslav Bajtoš bc541046f1 Merge pull request #488 from fabien/feature/op-hooks
Improve instance-level operation hooks

Close #488
2015-03-11 09:36:19 +01:00
Fabien Franzen 8605da3ac6 Improve instance-level operation hooks
"before delete" and "after delete" hooks receive `ctx.instance`
when a single model is being deleted.

"before save" hook receives `ctx.currentInstance` when triggered
by `prototype.updateAttributes()`.

Note that "after save" hook triggered by `prototype.updateAttributes()`
already provides `ctx.instance`.
2015-03-11 09:35:46 +01:00
Clark Wang 90e169c1a6 fix #429 Multiple Models can't mixin same class
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2015-03-11 16:08:50 +08:00
Raymond Feng 2a24273b4f Fix the test case 2015-03-10 21:26:36 -07:00
Raymond Feng 9083370e17 Merge pull request #498 from didikeke/master
fix foreign key dataType bug
2015-03-10 21:22:51 -07:00
didikeke 3644b85432 fix foreign key dataType bug 2015-03-11 11:30:40 +08:00
Raymond Feng 159be756ac Merge pull request #494 from strongloop/feature/allow-submodel-to-hide-base-properties
Allow submodel to hide base properties
2015-03-09 13:16:09 -07:00
Raymond Feng 6b04568707 Merge pull request #485 from fabien/feature/op-hooks-state
Implement #484 : hookState
2015-03-05 08:38:38 -08:00
Fabien Franzen 18b58558cc Reformat notifyObserversOf context argument 2015-03-05 15:53:34 +01:00
Fabien Franzen f42859f2e5 Implement operation hooks' context 2015-03-05 11:55:04 +01:00
Raymond Feng b7abb08da8 2.19.2
* Improved and corrected API docs (crandmck)

 * Fix problems in annotations that prvented validateAsync and validate functions from appearing in API docs. (crandmck)
2015-03-04 22:19:51 -08:00
crandmck d4b0a26a0e Improved and corrected API docs 2015-03-04 17:21:25 -08:00
crandmck 27f2e69981 Merge branch 'master' of https://github.com/strongloop/loopback-datasource-juggler 2015-03-03 16:59:14 -08:00
crandmck e81415ceda Fix problems in annotations that prvented validateAsync and validate functions from appearing in API docs. 2015-03-03 16:58:19 -08:00
Raymond Feng 666e15f8a4 2.19.1
* Make sure inclusion filter is applied to the target model (Raymond Feng)
2015-03-03 11:11:19 -08:00
Raymond Feng 33d3239b44 Allow submodel to hide base properties 2015-03-03 10:27:22 -08:00
Raymond Feng 4bbbf7906e Merge pull request #476 from strongloop/feature/fix-lb-1076
Make sure inclusion filter is applied to the target model
2015-03-02 11:04:12 -08:00
Miroslav Bajtoš 4fb4e356af 2.19.0
* Deprecate DAO events (Miroslav Bajtoš)

 * Deprecate Model hooks (Miroslav Bajtoš)

 * Add Promises to DAO (Partap Davis)

 * test for updateAll (rudzon)

 * enhance the coercion for boolean/date types (rudzon)

 * enhance updateAll to coerce the data per property definitions (rudzon)

 * relation-definition: remove trailing whitespace (Miroslav Bajtoš)
2015-03-02 17:06:04 +01:00
Raymond Feng 8042eeb3b1 Make sure inclusion filter is applied to the target model
See https://github.com/strongloop/loopback/issues/1076
2015-02-28 10:53:18 -08:00
Miroslav Bajtoš 17a999bfca Merge pull request #473 from strongloop/feature/deprecate-model-hooks-and-events
Deprecate model hooks and events
2015-02-27 19:37:39 +01:00
Miroslav Bajtoš 034bdcac07 Merge pull request #451 from partap/promises-dao
Promisify DAO
2015-02-27 17:10:07 +01:00
Miroslav Bajtoš 37d7721e0e Deprecate DAO events
List of deprecated events:

 - changed
 - deleted
 - deletedAll
2015-02-27 17:03:39 +01:00
Miroslav Bajtoš 03daaca9de Deprecate Model hooks
List of deprecated hooks:

 - beforeValidate
 - afterValidate
 - beforeCreate
 - afterCreate
 - beforeSave
 - afterSave
 - beforeUpdate
 - afterUpdate
 - beforeDestroy
 - afterDestroy

Also add a lightweight browser version of "depd", because the "depd"
does not support browser and it is not trivial to fix that.
This commits adds a lightweight implementation of depd's "deprecate"
function.
2015-02-27 16:58:24 +01:00
Partap Davis 1e6c453191 Add Promises to DAO
When a callback is omitted from a DAO method, return a Promise that
resolves to the value normally passed to the callback of that method.
If a callback is provided, behave normally.

This API will use native ES6 promises if available.  If not available,
or to force the use of another Promise library, you must assign the
global.Promise object.

e.g.:
global.Promise = require('bluebird')

Class methods affected:

- create
- updateOrCreate / upsert
- findOrCreate
- exists
- find
- findOne
- findById
- findByIds
- remove / deleteAll / destroyAll
- removeById / deleteById / destroyById
- count
- update / updateAll

Prototype methods affected:

- save
- delete / remove / destroy
- updateAttribute
- updateAttributes
- reload

Exceptions / edge cases:

- create() used to return the data object that was passed in, even if
  no callback was provided.  Now, if a callback is provided, it will
  return the data object, otherwise it will return a Promise.

- If create() is provided an array of data objects for creation, it
  will continue to always return the array. This batch creation mode
  does not support promises.

- findOrCreate() has a callback of the form: cb(err, instance, created),
  with the extra parameter indicating whether the instance was created
  or not. When called with its promise variant, the resolver will
  receive a single array parameter: [instance, created]
2015-02-26 13:45:37 -07:00
Raymond Feng 6891da4535 Merge pull request #470 from rudzon/master
Enhance updateAll to coerce the data per property definitions
2015-02-24 08:28:39 -08:00
rudzon 3953cc3e2f test for updateAll 2015-02-24 13:56:57 +02:00
rudzon dbe9329a37 enhance the coercion for boolean/date types 2015-02-24 13:55:57 +02:00
rudzon 35825f5e53 enhance updateAll to coerce the data per property definitions 2015-02-24 13:53:23 +02:00
Miroslav Bajtoš a46ff4bb8e Merge pull request #469 from strongloop/fix/trailing-whitespace
relation-definition: remove trailing whitespace
2015-02-24 12:26:10 +01:00