Commit Graph

2155 Commits

Author SHA1 Message Date
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
Miroslav Bajtoš 52e78ff5ae relation-definition: remove trailing whitespace 2015-02-24 11:36:13 +01:00
Raymond Feng fc0667fbf4 2.18.1
* Make sure models are migrated to avoid conflicts (Raymond Feng)

 * Add err checks (Raymond Feng)

 * Fix findByIds test cases (Raymond Feng)
2015-02-20 21:51:15 -08:00
Raymond Feng d92323a40c Merge pull request #462 from strongloop/feature/fix-ids-tests
Feature/fix ids tests
2015-02-20 21:46:44 -08:00
Raymond Feng 9fd3865f32 Make sure models are migrated to avoid conflicts 2015-02-20 21:44:49 -08:00
Raymond Feng a42e3b3d30 Add err checks 2015-02-20 21:14:48 -08:00
Raymond Feng 527d5f7a81 Fix findByIds test cases 2015-02-20 21:14:41 -08:00
Raymond Feng d5e71f1157 2.18.0
* Fix the idType so that it works with both MongoDB and RDBs (Raymond Feng)

 * Tidy up tests so that they will work with RDBs (Raymond Feng)

 * Fix JS style issues (Raymond Feng)

 * Add a new property option `defaultFn` (Miroslav Bajtoš)

 * Fix the null/undefined check (Raymond Feng)

 * Fix createdAt type so that it won't overflow SQL server int (Raymond Feng)

 * ModelBaseClass: promise mode for notifyObserversOf (Miroslav Bajtoš)

 * ModelBaseClass: support promise-based observers (Miroslav Bajtoš)

 * use lodash to update the findBelongsTo which now returns an array of matches (Bryan Clark)

 * Add $now as shortcut default value for date property (Pradnya Baviskar)

 * Fix `deleteById(id)` and other test failures (Miroslav Bajtoš)
2015-02-20 17:08:01 -08:00
Raymond Feng 5e0667eca3 Merge pull request #461 from strongloop/feature/fix-tests
Fix the idType so that it works with both MongoDB and RDBs
2015-02-20 16:40:17 -08:00
Raymond Feng 195752eaad Fix the idType so that it works with both MongoDB and RDBs 2015-02-20 16:39:48 -08:00
Raymond Feng bb6ddc8189 Merge pull request #460 from strongloop/feature/fix-tests
Tidy up tests so that they will work with RDBs
2015-02-20 16:16:14 -08:00
Raymond Feng 841f2d8f14 Tidy up tests so that they will work with RDBs 2015-02-20 16:10:25 -08:00
Raymond Feng e659e2f603 Fix JS style issues 2015-02-20 14:57:48 -08:00
Raymond Feng 4c99fbabba Merge pull request #459 from strongloop/feature/fix-test-date
Fix createdAt type so that it won't overflow SQL server int
2015-02-20 12:08:07 -08:00
Miroslav Bajtoš 081544edb5 Merge pull request #458 from strongloop/feature/property-defaultfn
Add a new property option `defaultFn`
2015-02-20 20:14:44 +01:00
Miroslav Bajtoš ba0f3c1616 Add a new property option `defaultFn`
The property allows developers to specify that the default value
should be retrieved via a named function.

Only two built-in functions are supported at the moment:

  "guid", "uuid" - generate a new GUID/UUID
  "now" - use the current date and time

Support for custom (user-provided) functions is not implemented yet.
2015-02-20 20:08:25 +01:00
Raymond Feng a713f25d61 Fix the null/undefined check 2015-02-20 09:55:09 -08:00
Raymond Feng 02503e7635 Fix createdAt type so that it won't overflow SQL server int 2015-02-20 09:33:54 -08:00
Miroslav Bajtoš c939efe1e7 Merge pull request #445 from PradnyaBaviskar/issue292
Add $now as shortcut default value for date property
2015-02-17 19:46:05 +01:00
Miroslav Bajtoš 9e0a22141a Merge pull request #449 from strongloop/feature/promises-for-operation-hooks
Promises for operation hooks
2015-02-17 18:22:58 +01:00
Miroslav Bajtoš 76ebdcb91b ModelBaseClass: promise mode for notifyObserversOf
Support both promise and callback styles in
ModelBaseClass.notifyObserversOf.

When there is no callback supplied, the method returns a promise that
is resolved (or rejected) with the result.
2015-02-17 18:19:21 +01:00
Miroslav Bajtoš a2836fbb56 ModelBaseClass: support promise-based observers
Allow the observer functions passed to `ModelBaseClass.observe`
to return a promise instead of calling the callback.
2015-02-17 17:31:42 +01:00
Raymond Feng a44e45b30a Merge pull request #394 from clarkbw/hasManyThroughKeyThrough
hasMany through doesn't set the through key value
2015-02-16 22:45:06 -08:00
Bryan Clark 98fcf6b52c use lodash to update the findBelongsTo which now returns an array of matches 2015-02-16 15:36:51 -08:00
Pradnya Baviskar aba7d0dc10 Add $now as shortcut default value for date property 2015-02-16 11:32:24 +05:30
Miroslav Bajtoš 03717d3798 Merge pull request #446 from strongloop/fix/ci-build
Fix `deleteById(id)` and other test failures
2015-02-13 19:20:22 +01:00
Miroslav Bajtoš 46ff76dda0 Fix `deleteById(id)` and other test failures 2015-02-13 09:34:40 -08:00
Raymond Feng b4189bf997 2.17.0
* Add an optional `options` argument to all CRUD methods (Raymond Feng)

 * Upgrade deps (Raymond Feng)

 * Remove workaround for perfomance degradation (Denis Bardadym)

 * Change equal to eql to support mongodb ObjectID (Raymond Feng)

 * Enhance the coercion for boolean/date types (Raymond Feng)

 * Make sure base properties/settings are merged into the submodel (Raymond Feng)

 * support optimized findOrCreate (Clark Wang)

 * Fix the perf around should.not.equal for complex objects (Raymond Feng)

 * testcase for #420 (Andrey Loukhnov)

 * use findOrCreate in hasOne#create (Clark Wang)

 * Create model foreign key matching type of opposite part of relation (even if it has a custom field type) (Andrey Loukhnov)

 * minor formatting issues (trailing spaces and such) and .editorconfig (Andrey Loukhnov)
2015-02-11 20:59:24 -08:00
Raymond Feng cc1791b01d Merge pull request #423 from clarkorz/hasOne-findOrCreate
use findOrCreate in hasOne#create
2015-02-11 20:51:33 -08:00
Raymond Feng 96c39509c9 Merge branch 'clarkorz-featrue/support-connector-findOrCreate' 2015-02-11 20:50:49 -08:00
Raymond Feng bcbb9c580d Merge branch 'featrue/support-connector-findOrCreate' of https://github.com/clarkorz/loopback-datasource-juggler into clarkorz-featrue/support-connector-findOrCreate 2015-02-11 20:49:51 -08:00
Raymond Feng a8f3d21b65 Merge pull request #436 from strongloop/feature/fix-issue-293
Make sure base properties/settings are merged into the submodel
2015-02-11 16:13:00 -08:00
Raymond Feng 9bac813f59 Merge pull request #435 from strongloop/feature/add-options-to-crud-methods
Add an optional `options` argument to all CRUD methods
2015-02-11 10:31:18 -08:00
Raymond Feng 760ac97902 Add an optional `options` argument to all CRUD methods 2015-02-10 23:57:05 -08:00
Raymond Feng 770c69b1d4 Upgrade deps 2015-02-10 09:49:54 -08:00
Raymond Feng 4c2d508151 Merge pull request #439 from btd/master
Remove workaround for perfomance degradation in should.js
2015-02-10 09:47:42 -08:00
Denis Bardadym 32e534732c Remove workaround for perfomance degradation 2015-02-10 13:28:47 +03:00
Raymond Feng 9cfc47bc8f Merge pull request #437 from strongloop/feature/enhance-boolean-coercion
Enhance the coercion for boolean/date types
2015-02-09 14:57:27 -08:00
Raymond Feng 919d32c4dc Change equal to eql to support mongodb ObjectID 2015-02-08 11:14:51 -08:00