Commit Graph

141 Commits

Author SHA1 Message Date
Fabien Franzen 170dc661f4 Fix error messages, should be lowercase 2014-08-29 21:30:42 +02:00
Fabien Franzen b27fd6527e Use the correct dataSource for modelFrom/modelTo 2014-08-22 21:38:28 +02:00
Jaka Hudoklin 000c380a48 Emit deleted event on delete for embedsMany relations
Signed-off-by: Jaka Hudoklin <jakahudoklin@gmail.com>
2014-08-22 16:02:01 +02:00
Raymond Feng a43bed1f1b Merge branch 'feature/to-one-update' of github.com:fabien/loopback-datasource-juggler into fabien-feature/to-one-update 2014-08-20 14:30:38 -07:00
Raymond Feng f5839fb6ae Merge branch 'feature/embeds-one' of github.com:fabien/loopback-datasource-juggler into fabien-feature/embeds-one 2014-08-20 14:28:45 -07:00
Raymond Feng af329e3a66 Save the instance even the callback is not present 2014-08-20 14:22:47 -07:00
Fabien Franzen 20e5d3c01b Validate embedded models by default 2014-08-20 08:58:08 -07:00
Fabien Franzen 1ec5357a6c Implemented embedsOne 2014-08-20 08:58:08 -07:00
Fabien Franzen af99a8d344 Implemented belongsTo update/destroy on scope 2014-08-20 16:46:54 +02:00
Fabien Franzen 12ebaf77f2 Implemented hasOne destroy() 2014-08-20 15:58:45 +02:00
Fabien Franzen 123b2558a1 Implemented hasOne update() 2014-08-20 15:54:47 +02:00
Fabien Franzen 1d5079d811 Implement update() on embedsOne scope 2014-08-20 15:37:40 +02:00
Fabien Franzen a446551a59 Fix relations for RDBMS connectors (mysql, postgresql)
- fix tests (explicit model/property definitions)
- fix include vs. RDBMS model strictness
2014-08-20 14:03:38 +02:00
Fabien Franzen 6f815526b0 Validate embedded models by default 2014-08-19 22:15:30 +02:00
Fabien Franzen 7c901af6d9 Implemented embedsOne 2014-08-19 22:10:35 +02:00
Raymond Feng c3c2907248 Merge pull request #224 from fabien/fix/ldl-polymorphic
Properly handle LDL for polymorphic relations
2014-08-16 08:15:09 -07:00
Fabien Franzen b4b1c784dd HasMany exists should use internal findById
This limits the scope correctly, taking polymorphics into account.

(the foreign key check is actually obsolete I think)
2014-08-16 13:04:13 +02:00
Fabien Franzen ad780604e1 Properly handle LDL for polymorphic relations 2014-08-16 11:03:16 +02:00
Fabien Franzen 0e348b0333 Fixed duplicate code 2014-08-15 18:51:19 +02:00
Fabien Franzen 6b0bbed780 Merge branch 'fix/relation-tests' of https://github.com/fabien/loopback-datasource-juggler into fix/relation-tests 2014-08-15 18:43:20 +02:00
Fabien Franzen 96a276a12b Refactor embedsMany - auto-save parent
With this change, saving an embedded model now correctly updates the
parent model.

Before, a separate `save()` call on the parent was required, contrary
to other relation types.
2014-08-15 18:40:33 +02:00
Fabien Franzen 8193f402bb Refactor polymorphic relations, fix inverse #215
See #215 - when creating a related item through a the inverse of a
polymorphic HABTM relation,
the through-model was not created correctly. By refactoring the
specifics into the `polymorphic`
property of a RelationDefinition, it's now possible to handle this
correctly.
2014-08-15 18:35:31 +02:00
Fabien Franzen 78e2c9c9d4 Clarified tests, fixed BelongsTo.prototype.create
Added clarified test-case based on previous documentation example.

Fixed BelongsTo.prototype.create - although the foreignKey was set on
the model instance,
it was never actually persisted, unless you'd issue a separate call to
save the 'parent' model.
2014-08-15 18:35:31 +02:00
Raymond Feng d7900a8a21 Merge pull request #211 from fabien/fix/relationTypes
Fix relationTypes
2014-08-15 09:29:22 -07:00
Raymond Feng da4482d1cf Merge pull request #213 from fabien/feature/scope-rel-methods
Implement scope.defineMethod/relation.defineMethod
2014-08-15 09:24:24 -07:00
Fabien Franzen c2f9ee381c Implement embedded.destroy() integration 2014-08-15 15:24:00 +02:00
Fabien Franzen 21801058c9 Refactor embedsMany - auto-save parent
With this change, saving an embedded model now correctly updates the
parent model.

Before, a separate `save()` call on the parent was required, contrary
to other relation types.
2014-08-15 15:12:02 +02:00
Fabien Franzen c3c2c85ce4 Refactor polymorphic relations, fix inverse #215
See #215 - when creating a related item through a the inverse of a
polymorphic HABTM relation,
the through-model was not created correctly. By refactoring the
specifics into the `polymorphic`
property of a RelationDefinition, it's now possible to handle this
correctly.
2014-08-15 12:55:10 +02:00
Fabien Franzen 35850f6632 Clarified tests, fixed BelongsTo.prototype.create
Added clarified test-case based on previous documentation example.

Fixed BelongsTo.prototype.create - although the foreignKey was set on
the model instance,
it was never actually persisted, unless you'd issue a separate call to
save the 'parent' model.
2014-08-15 11:28:25 +02:00
Fabien Franzen cd3ad32bb7 Fix formatting 2014-08-14 20:12:17 +02:00
Fabien Franzen 7d847f25dc Fix scopeMethods closure issue 2014-08-14 20:12:17 +02:00
Fabien Franzen a67759dcbf Refactored embedsMany (relationName vs. propertyName) 2014-08-14 20:12:16 +02:00
Fabien Franzen 807a6aaf3f Refactor modelTo logic into lookupModelTo 2014-08-14 19:43:30 +02:00
Fabien Franzen 710ad35b39 Implement scope.defineMethod/relation.defineMethod 2014-08-13 11:28:23 +02:00
Fabien Franzen 93fab448bc Tiny fix: use setAttributes 2014-08-11 13:03:51 +02:00
Raymond Feng 3d5ec63c99 Pass options into scope 2014-08-08 09:25:49 -07:00
Fabien Franzen ef65ffee48 Changed normalization api - enabled hasOne remoting 2014-08-01 11:24:41 +02:00
Fabien Franzen 090c738bb5 Correctly handle remoting of scope methods 2014-07-30 17:30:21 +02:00
Fabien Franzen af0ca5b108 Handle remoting of custom scope methods 2014-07-30 16:46:05 +02:00
Fabien Franzen e38c92af87 ReferencesMany fixes after LB integration tests 2014-07-30 15:01:55 +02:00
Fabien Franzen 5cee6a4b79 Fixed embedsMany after LB integration 2014-07-30 13:22:20 +02:00
Raymond Feng 7a9b64f1bf Fix the test failure for mongodb 2014-07-29 22:19:52 -07:00
Fabien Franzen e888b8cff9 Allow custom scopeMethods option (obj/fn) for relation scopes 2014-07-29 22:59:44 +02:00
Fabien Franzen 06f2b32c21 Renamed EmbedsMany 'reference' option to 'belongsTo' 2014-07-29 21:56:59 +02:00
Fabien Franzen 1782b439f1 Implemented referencesMany 2014-07-29 21:46:12 +02:00
Fabien Franzen 60fd39d311 Added option: reference to enable embedsMany add/remove 2014-07-29 17:43:30 +02:00
Fabien Franzen b18384459a Implemented findByIds 2014-07-29 15:01:47 +02:00
Fabien Franzen 13cee9502c Tests for polymorphic embedsMany 2014-07-29 13:57:49 +02:00
Fabien Franzen da303b72a5 Implemented more complex scenaro: embedsMany + relations
The test case will denormalize data into the embedded object,
and re-use the actual related object id as its own id.
2014-07-29 12:02:52 +02:00
Fabien Franzen 6ed7a0a5f2 Convenience embedsMany accessors: at(idx), get(id), set(id, data) 2014-07-29 10:51:33 +02:00
Raymond Feng cb43114ab7 Fix test cases 2014-07-28 16:15:37 -07:00
Raymond Feng 1b44a6d779 Merge branch 'feature/embed-hasmany' of github.com:fabien/loopback-datasource-juggler into fabien-feature/embed-hasmany 2014-07-28 14:51:16 -07:00
Raymond Feng 75403ef929 Merge branch 'feature/polymorphic-rel' of github.com:fabien/loopback-datasource-juggler into fabien-feature/polymorphic-rel
Fix test cases
2014-07-28 14:22:45 -07:00
Raymond Feng 5221d12305 Remove unused data 2014-07-28 09:36:04 -07:00
Laurent Chenay 04a56e2ea6 Fix HEAD on relation hasMany 2014-07-28 11:36:32 +02:00
Fabien Franzen 309105c4ad Updated remaining relations to use polymorphicParams 2014-07-28 11:12:20 +02:00
Fabien Franzen 7ddfbb6409 polymorphics can now be declared using object 2014-07-28 10:44:26 +02:00
Fabien Franzen 4e76c2a77f typeTo => discriminator 2014-07-28 10:18:42 +02:00
Fabien Franzen e1ecb4b95f Require unique ids for embedded items 2014-07-27 17:30:10 +02:00
Fabien Franzen 43e11af942 Test build of embedsMany 2014-07-27 17:16:25 +02:00
Fabien Franzen cd2cc68905 Minor fix 2014-07-27 16:56:30 +02:00
Fabien Franzen 1487a592c1 Added validation for embedded items (optional) 2014-07-27 16:54:01 +02:00
Fabien Franzen 59a957b538 Implemented embedsMany relation 2014-07-27 16:30:45 +02:00
Raymond Feng 1a989041ed Fix a regression where undefined id should not match any record 2014-07-27 00:38:50 -07:00
Fabien Franzen 5a5aa3f14d Minor tweaks; pass-through properties/scope for hasAndBelongsToMany 2014-07-26 21:32:24 +02:00
Fabien Franzen 5e30ec8637 Implemented polymorphic hasMany through inverse
Added option invert: true to enable inverse polymorphic hasMany
relations.

Fixed missing fk1 in query of HasManyThrough.prototype.exists.
2014-07-26 21:11:25 +02:00
Fabien Franzen d1896553fd More hasAndBelongsToMany tests 2014-07-26 17:20:25 +02:00
Fabien Franzen 9f94ec9bde Minor cleanup 2014-07-26 15:23:40 +02:00
Fabien Franzen 00dfe563eb Implemented polymorphic hasOne
Signed-off-by: Fabien Franzen <info@atelierfabien.be>
2014-07-26 15:20:46 +02:00
Fabien Franzen 295e6fc1f1 Implemented polymorphic hasAndBelongsToMany 2014-07-26 14:54:54 +02:00
Fabien Franzen 9b97e1ae77 Implemented polymorphic hasMany 2014-07-26 12:47:55 +02:00
Miroslav Bajtoš cd4dba79dc relation: add `scope._target` for `hasOne`
Add `_target` property to the scope method created by `hasOne`
relationship. The `_target` property is used by loopback-sdk-angular.
2014-07-24 20:22:11 +02:00
Fabien Franzen 687eb9888b Added test for belongsTo scope/properties
Note: its seems that keyFrom and keyTo were mistakingly reversed in
BelongsTo.prototype.create, please double check. The added test cases
now pass with pk/fk switched.
2014-07-23 11:10:44 +02:00
Fabien Franzen bc4076f35e Implement scope/properties for BelongsTo (+ fix foreign key matching) 2014-07-22 22:09:29 +02:00
Raymond Feng 61d315cb28 Merge pull request #180 from strongloop/feature/refactor-relation-remoting
Move relation remoting to loopback
2014-07-22 11:13:07 -07:00
Jaka Hudoklin b1a1894635 add support for relationship options
Signed-off-by: Jaka Hudoklin <jakahudoklin@gmail.com>
2014-07-21 22:39:06 +02:00
Raymond Feng ad22b025a6 Move relation remoting to loopback 2014-07-16 16:36:43 -07:00
Raymond Feng fc710ca55a Merge branch 'master' into 2.0 2014-07-15 17:09:20 -07:00
Raymond Feng ee6da650e9 Test instance or id by the model type 2014-07-15 16:09:54 -07:00
Raymond Feng f3dbc6ca5f Remoting methods for hasMany through 2014-07-15 08:50:34 -07:00
Fabien Franzen 48c4f25b09 Renamed mapping to properties 2014-07-12 00:02:16 +02:00
Fabien Franzen 6aaa3f216e RelationDefinition applyScope/applyMapping
Add the ability to set static/dynamic filtering (where, order, limit,
skip, fields …) and property mapping/transfer (de-normalization) for
hasMany/hasOne.
2014-07-11 15:29:47 +02:00
Raymond Feng 4515491318 Make sure type of the foreign key match the primary key
See https://github.com/strongloop/loopback/issues/353
2014-06-26 23:38:04 -07:00
Raymond Feng ce8254125f Merge branch 'master' into 2.0 2014-06-21 12:53:46 -07:00
Raymond Feng 332579ec87 Synchronize with cachedRelations 2014-06-21 11:44:33 -07:00
Raymond Feng cbee68706f Remove remoting metadata 2014-06-20 23:54:46 -07:00
Raymond Feng 177752e144 Add more jsdocs 2014-06-19 11:13:24 -07:00
Raymond Feng e2ab9ccc93 Adding back the remoting metadata 2014-06-16 13:46:17 -07:00
Raymond Feng 2db43c58e5 Add support for hasOne 2014-06-16 01:17:37 -07:00
Raymond Feng 34c1998f04 Fix the hasMany through connection 2014-06-16 00:36:12 -07:00
Raymond Feng 1406c22a64 Refactor relation into classes 2014-06-15 15:53:58 -07:00