Commit Graph

2111 Commits

Author SHA1 Message Date
Miroslav Bajtoš 1fd6eff10f Intent-based hooks for persistence
This patch introduces a new API for "intent-based" hooks. These hooks
are not tied to a particular method (e.g. "find" or "update"). Instead,
they are triggered from all methods that execute a particular "intent".

The consumer API is very simple, there is a new method
Model.observe(name, observer), where the observer is function
observer(context, callback).

Observers are inherited by child models and it is possible to register
multiple observers for the same hook.

List of hooks:

 - query
 - before save
 - after save
 - after delete
2015-01-29 08:43:52 +01:00
Miroslav Bajtoš b3d07ebbe8 ModelBaseClass: implement async observe/notify
Implement infrastructure for intent-based hooks.
2015-01-29 08:43:50 +01:00
Miroslav Bajtoš f9b0ac482c Upgrade `should` to the latest 1.x version 2015-01-29 08:41:19 +01:00
Raymond Feng 577def97f8 Merge pull request #409 from billinghamj/master
Fixed nullCheck in validations for undefined attributes
2015-01-27 14:20:53 -08:00
James Billingham 28f3f5d9f8 Fixed nullCheck in validations to correct behavior when dealing with undefined attributes 2015-01-27 22:18:47 +00:00
Raymond Feng 70833b2a2b Merge pull request #407 from fabien/fix/apply-props
Supply target to applyProperties function
2015-01-26 11:19:26 -08:00
Fabien Franzen a08ef823be Supply target to applyProperties function 2015-01-26 19:09:29 +01:00
Clark Wang 2e9e2dd192 fix id property for composite ids
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2015-01-22 10:39:47 +08:00
Raymond Feng b2f41f4344 Merge pull request #402 from clarkorz/fix/ids-sort
fix id properties should sort by its index
2015-01-21 08:29:07 -08:00
Clark Wang c37de7f008 fix id properties should sort by its index
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2015-01-21 20:16:34 +08:00
Christian Enevoldsen 7372fafc97 Fixed typos and logic for protected properties 2015-01-20 21:32:31 +01:00
Christian Enevoldsen d39f539413 adds support for protected properties. 2015-01-20 20:58:52 +01:00
Raymond Feng 0af69794a3 Merge pull request #399 from clarkorz/embeds-belongsTo
support embeds data for belongsTo relation
2015-01-19 15:25:11 -08:00
Clark Wang 83c3a17f87 support embeds data for belongsTo relation
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2015-01-19 22:56:09 +08:00
Miroslav Bajtoš 0019501a8b Merge tag 'v2.14.1'
2.14.1

 * Fix detection of `util.inspect` version (Miroslav Bajtoš)

 * fix recursive calls if create belongsTo model in beforeCreate hook (Clark Wang)
2015-01-15 08:54:01 +01:00
Miroslav Bajtoš a5c8e2eb58 Merge branch 'release/2.14.1' into production 2015-01-15 08:53:59 +01:00
Miroslav Bajtoš 825b4d5ba3 v2.14.1 2015-01-15 08:53:57 +01:00
Miroslav Bajtoš 2c2c40362d Merge pull request #395 from strongloop/fix/detection-of-util.inspect-version
Fix detection of `util.inspect` version
2015-01-15 08:52:25 +01:00
Miroslav Bajtoš 2e98c51571 Fix detection of `util.inspect` version
Improve the detection to work in browser too. This fixes a regression
introduced in e4fc3878.
2015-01-15 08:45:52 +01:00
Raymond Feng 4aeb831bd5 Merge pull request #358 from clarkorz/fix/beforeCreate-belongsTo
fix recursive calls if create belongsTo model in beforeCreate hook
2015-01-14 14:42:29 -08:00
Raymond Feng 8c32dcef64 Merge tag 'v2.14.0'
2.14.0

 * Remove console.log (Raymond Feng)

 * Fix for #369 (Dallon Feldner)

 * Fix virtual id get function. (Berkeley Martinez)

 * Fix Model.prototype.inspect (Miroslav Bajtoš)

 * Include property value in the error message (Miroslav Bajtoš)

 * Update datasource.js (Rand McKinney)

 * Change Model to BaseModel for clarity (Fabien Franzen)

 * Don't coerce nested objects into Model instances (Fabien Franzen)
2015-01-14 12:44:26 -08:00
Raymond Feng abd0d244cc Merge branch 'release/2.14.0' into production 2015-01-14 12:44:24 -08:00
Raymond Feng 0ff7e3de91 v2.14.0 2015-01-14 12:44:22 -08:00
Raymond Feng 8dfe877639 Remove console.log 2015-01-14 11:51:47 -08:00
Raymond Feng f1bdf50e2a Merge pull request #387 from fabien/fix/coerce
Don't coerce nested objects into Model instances
2015-01-14 11:43:38 -08:00
Raymond Feng a2b5d6410a Merge pull request #389 from strongloop/feature/include-value-in-validation-error-message
Include property value in the error message
2015-01-14 11:37:10 -08:00
Raymond Feng 2e08d48ad3 Merge pull request #390 from r3dm/fix/call-idNames
Fix virtual id get function.
2015-01-14 11:31:55 -08:00
Raymond Feng 1236171962 Merge pull request #391 from dallonf/patch-1
Fix for #369
2015-01-12 15:39:45 -08:00
Dallon Feldner e7fedc2926 Fix for #369
Remember, folks, `typeof null === 'object'`.
2015-01-12 17:38:21 -06:00
Berkeley Martinez 3fac41985b Fix virtual id get function. 2015-01-12 08:43:55 -08:00
Miroslav Bajtoš e4fc38788f Fix Model.prototype.inspect
Return the raw object data when running on Node v0.11.14+
That way all `inspect` options are always preserved.

When running on older version:
 - Honour the depth argument passed to the custom `inspect` function.
 - Disable color output, becase there is now way how to detect whether
   colors were enabled or disabled by the top-level caller.
2015-01-12 17:12:18 +01:00
Miroslav Bajtoš 9b759c95ac Include property value in the error message
When building a list of errors for `ValidationError.message`, include
the values of invalid properties too.

In order to keep the message reasonably short, the values are truncated
at approx 32 characters.
2015-01-12 17:12:18 +01:00
Rand McKinney 2270ba4db4 Update datasource.js
Small fix to JSdoc
2015-01-08 15:30:17 -08:00
Fabien Franzen a19b778cbd Change Model to BaseModel for clarity 2015-01-08 15:44:28 +01:00
Fabien Franzen a24b222a72 Don't coerce nested objects into Model instances
For queries, this is undesirable. It also affects
loopback-connector-mongodb's ability to perform nested queries (it
expects plain objects to work correctly, and to allow $elemMatch for
example).
2015-01-08 15:34:04 +01:00
Raymond Feng cf0d9f730b Merge tag 'v2.13.0'
2.13.0

 * added test for sorting undefined values (Christian Vette)

 * Fix the floating number comparison (Raymond Feng)

 * Fix bad CLA URL in CONTRIBUTING.md (Ryan Graham)

 * replace deprecated function __defineGetter__ (bitmage)

 * add a flag to callback of findOrCreate to indicate find or create (Clark Wang)

 * fix sorting of undefined values with multiple columns (Christian Vette)

 * code style (cvette)

 * fix sorting with undefined in memory connector (cvette)

 * Added support for inline parameters like: new GeoPoint(-34, 150) (Simo Moujami)

 * fix default include in default scope fails findById (Clark Wang)

 * Added test for toString() (Simo Moujami)

 * Additional formatting (Simo Moujami)

 * Fixed constructor parameters and added bdd tests for constructor validation (Simo Moujami)

 * Fixed indentation (Simo Moujami)

 * Added mocha tests for GeoPoint (Simo Moujami)

 * renamed intermediary variable (Simo Moujami)

 * Fixed the haversine formula to calculate distance between 2 points properly (Simo Moujami)
2015-01-07 13:58:09 -08:00
Raymond Feng dfd26e4c23 Merge branch 'release/2.13.0' into production 2015-01-07 13:58:08 -08:00
Raymond Feng 0c4bc5e40e v2.13.0 2015-01-07 13:58:06 -08:00
Raymond Feng eac7526e80 Merge pull request #379 from cvette/memory-order-fix
fix sorting of undefined values in memory connector
2015-01-06 09:39:49 -08:00
Christian Vette 99acd364d2 added test for sorting undefined values 2015-01-05 21:56:17 +01:00
Raymond Feng f4c540ca02 Merge pull request #382 from clarkorz/feature/findOrCreate-flag
add a flag to callback of findOrCreate to indicate find or create
2015-01-05 11:18:06 -08:00
Raymond Feng f20eefc8b5 Merge pull request #383 from TorchlightSoftware/es-compat
replace deprecated function __defineGetter__
2015-01-05 10:53:53 -08:00
Raymond Feng 88b85a7fa2 Fix the floating number comparison 2015-01-05 10:53:26 -08:00
Ryan Graham efdbe69039 Fix bad CLA URL in CONTRIBUTING.md 2014-12-29 08:27:46 -08:00
bitmage 803e75e9b9 replace deprecated function __defineGetter__ 2014-12-28 14:14:12 -07:00
Clark Wang ce2b580ccd add a flag to callback of findOrCreate to indicate find or create
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-12-25 22:19:15 +08:00
Christian Vette e45407256e fix sorting of undefined values with multiple columns 2014-12-22 21:06:01 +01:00
cvette 31c7973763 code style 2014-12-22 18:54:56 +01:00
cvette a6b8ca70af fix sorting with undefined in memory connector 2014-12-22 18:45:39 +01:00
Ritchie Martori efe4601fdb Merge pull request #370 from simoami/master
Fixed the haversine formula to calculate distance between 2 points
2014-12-18 15:08:42 -08:00