Fabien Franzen
433b89a78a
embedsMany - implement sync scope getter
2014-09-04 21:51:59 +02:00
Fabien Franzen
92a76d3edb
hasAndBelongsToMany - test sync scope getter
2014-09-04 21:30:41 +02:00
Fabien Franzen
80b71438a7
polymorphic hasMany - test sync scope getter
2014-09-04 21:29:21 +02:00
Fabien Franzen
e502bd4459
hasOne - test sync scope getter
2014-09-04 21:27:40 +02:00
Fabien Franzen
98a75103a1
hasMany through - sync scope getter
2014-09-04 21:25:26 +02:00
Fabien Franzen
3efe7ab354
Scope method should return cached relation value (sync)
2014-09-04 21:23:24 +02:00
Fabien Franzen
830a3f6f1a
Remove legacy Schema references
2014-09-04 18:01:04 +02:00
Fabien Franzen
7b788a2903
getTransientSchema => getTransientDataSource
2014-09-04 17:56:26 +02:00
Fabien Franzen
72930bf20b
Re-use modelBuilder - correctly fixes lookup
2014-09-04 17:54:42 +02:00
Fabien Franzen
2c0ffee2d3
Polymorphic lookup from all registered dataSources
...
Polymorphic model lookup was previously limited to the same dataSource
as the modelFrom model, which turns out to be too restrictive. This was
uncovered by the use of a Transient model, not being able to lookup a
PersistedModel.
2014-09-04 17:31:53 +02:00
Fabien Franzen
4abe7f4954
Isolate transient schema helper
2014-09-04 15:33:12 +02:00
Raymond Feng
b22dae3c7a
Merge pull request #281 from clarkorz/fix/hasManyThrough-custom-relation-name
...
Allows the belongsTo relations in through model to have custom name
2014-09-03 08:14:59 -07:00
Clark Wang
1393bd0759
Refector tests and codes
...
1. remove error
2. prune tests
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 21:51:21 +08:00
Clark Wang
b6f2026493
Refactor tests and codes
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 19:58:39 +08:00
Raymond Feng
cf3128467c
Merge pull request #275 from clarkorz/feature/add-with-through-data
...
Allow to add connection with through data for HasManyThrough relation
2014-09-02 22:44:01 -07:00
Clark Wang
26547f8461
Refactor codes into same if condition
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 12:31:09 +08:00
Clark Wang
902885c3f8
Remove only
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 11:30:32 +08:00
Clark Wang
69b01b23f9
Add tests for hasMany through between same model
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 11:29:32 +08:00
Clark Wang
cb2aeb96fb
Fix hasMany through can't custom relation name
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-09-03 11:04:58 +08:00
Clark Wang
565b85555c
Allow to add connection with through data for HasManyThrough relation
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-08-31 21:40:18 +08:00
Fabien Franzen
f31a9b13be
Updated embedded relations to use transient connector
...
embedsMany will now use a connector's generated method, when defined.
Also, the id property type is now inferred correctly, making the autoId
option obsolete. However, a new option, forceId, can be set to enforce
the use of auto-generated ids, preventing any explicitly (user-)set id
values.
2014-08-30 11:43:36 +02:00
Fabien Franzen
bd9895ebd6
Implemented Transient connector
2014-08-30 10:53:10 +02:00
Fabien Franzen
170dc661f4
Fix error messages, should be lowercase
2014-08-29 21:30:42 +02:00
Fabien Franzen
a4db887493
Implement where arg on scoped count and destroyAll
2014-08-26 14:54:19 +02:00
Raymond Feng
6bc2a53afb
Tweak the model names used by tests to avoid mssql conflicts
2014-08-25 22:17:51 -07:00
Fabien Franzen
3f0380296a
Fix side-effects of PR #237 - see #242
2014-08-21 10:44:55 +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
a1c1a9c658
Fix the embedsOne test cases
2014-08-20 11:42:14 -07:00
Raymond Feng
5088c4dd74
Fix test cases
2014-08-20 08:58:08 -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
Raymond Feng
0290109cdb
Fix test cases
2014-08-19 15:23:37 -07: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
Fabien Franzen
ad780604e1
Properly handle LDL for polymorphic relations
2014-08-16 11:03:16 +02:00
Raymond Feng
f37941dfd6
Fix the test cases to avoid hard-coded ids
2014-08-15 13:48:38 -07:00
Raymond Feng
03d94a86e5
Merge pull request #219 from fabien/fix/relation-tests
...
Fix BelongsTo.prototype.create + remaining issues with new relation types
2014-08-15 09:46:27 -07:00
Fabien Franzen
94310549cf
Implement embedded.destroy() integration
2014-08-15 18:41:06 +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
Raymond Feng
62db2155e4
Merge pull request #212 from offlinehacker/relations_count
...
add count to relations
2014-08-15 09:37:50 -07: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
Fabien Franzen
710ad35b39
Implement scope.defineMethod/relation.defineMethod
2014-08-13 11:28:23 +02:00
Jaka Hudoklin
0d44cdc573
add count to relations
...
Signed-off-by: Jaka Hudoklin <jakahudoklin@gmail.com>
2014-08-12 14:44:33 +02:00
Raymond Feng
950be998bc
Fix the test case so that it works with other DBs
2014-08-08 09:39:36 -07:00
Raymond Feng
6239d8fde5
Merge branch 'patch-4' of github.com:lchenay/loopback-datasource-juggler into lchenay-patch-4
2014-07-30 21:34:41 -07: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
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
296bb0d73e
Minor touchups
2014-07-29 14:05:18 +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
Laurent Chenay
b336166acc
Add test to protect the use of include in related method
2014-07-29 11:05:57 +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
Fabien Franzen
7ddfbb6409
polymorphics can now be declared using object
2014-07-28 10:44:26 +02:00
Fabien Franzen
43e11af942
Test build of embedsMany
2014-07-27 17:16:25 +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
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
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
973c96268f
Fix scoped destroyAll: only use 'where', not full 'filter' args
2014-07-24 15:55:00 +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
Raymond Feng
82c6c8e851
Make sure related properties are defined for RDBMS
2014-07-15 16:10:37 -07:00
Raymond Feng
f3dbc6ca5f
Remoting methods for hasMany through
2014-07-15 08:50:34 -07:00
Fabien Franzen
03617b58df
Sign-off
...
Signed-off-by: Fabien Franzen <info@atelierfabien.be>
2014-07-12 00:24:07 +02: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
177752e144
Add more jsdocs
2014-06-19 11:13:24 -07:00
Raymond Feng
2db43c58e5
Add support for hasOne
2014-06-16 01:17:37 -07:00
Miroslav Bajtoš
4da4c65faa
Re-enable skipped test.
...
test/relations: hasMany should fetch all scoped instances
The test is passing with the current implementation.
2014-04-02 19:35:14 +02:00
Miroslav Bajtoš
abf57ff497
scope: add _targetClass to scope property
...
Store the class of the results returned by a scope find method.
This class is different from the "targetClass" when the relations
is using a third "through" model (e.g. hasAndBelongsToMany).
2014-04-02 19:32:37 +02:00
Raymond Feng
b42f7d2498
Remove the disconnect to avoid race condition
2014-03-27 13:56:24 -07:00
Raymond Feng
2b8c1ebaee
Reformat the code
2014-01-24 09:09:53 -08:00
Raymond Feng
8e01e17bdb
Add support for nesting objects with an array
2013-07-12 18:59:43 -07:00
Ritchie Martori
dbd5efed50
Revert adapter serialization. Remove geo point distance indicator.
2013-07-01 13:16:51 -07:00
Ritchie Martori
008b406dd7
model.find => model.findById, model.all => model.find
2013-06-24 12:42:58 -07:00
Anatoliy Chakkaev
83027f9ead
Accept related objects when creating instance #247
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
eecbd32d07
Allow null properties for headless models
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
a67f75f0be
Check types of sync and async getters created by belongsTo, close #266
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
a73f53521e
Fix m2m: only add fk when hasMany have no "through"
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
c9e97744dd
Many-to-many relation
...
- hasMany {through: Class}
- hasAndBelongsToMany
- some specs in relations.test.js
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
136ea91fbf
Organize model.js
2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev
43f395d653
Manually require init
2013-04-06 14:57:12 +04:00
Anatoliy Chakkaev
704bc965bd
Find on hasMany scope method
2013-04-04 00:46:41 +04:00
Anatoliy Chakkaev
349931780a
Automigrate before relation tests
2013-03-31 15:24:03 +04:00
Anatoliy Chakkaev
839791de2f
Upd tests
...
- skipping
- hook up redis-hq
- some stuff should be moved to advanced-querying tests
2013-03-29 11:43:04 +04:00
Anatoliy Chakkaev
2d6cc9aaee
Mongodb tolerance
2013-03-27 21:53:07 +04:00
Anatoliy Chakkaev
de28603460
Added short syntax for belongsTo
2013-03-27 00:48:14 +04:00
Anatoliy Chakkaev
f76b56d2fe
Another way to define belongsTo
2013-03-26 04:39:47 +04:00