Partap Davis
29eb3434c7
Promisify model relation methods
...
When a callback is omitted from a method on a model relation that
supports promises, return that promise. This includes all the standard
DAO methods, as well as any user-defined methods that return promises.
e.g.:
mylist.todos.create({name: 'Item 1'}) // returns Promise
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')
Relations affected:
- BelongsTo
- HasOne
- HasMany
- HasManyThrough
- HasAndBelongsToMany
- ReferencesMany
- EmbedsOne
Exceptions:
The EmbedsMany relation has not been promisified, because most of the
methods return synchronous values.
The base relation getter method [e.g.: mylist.todos()] has not been
promisified, due to its default caching behavior.
New Methods:
- getAsync(condition, cb)
A new method "getAsync()" has been added to all relations except
EmbedsMany, which always fetches from the datasource rather than from
the cache. It takes an optional "where" condition (except for HasOne
and BelongsTo) and an optional callback. If the callback is omitted,
a Promise is returned.
2015-04-07 11:41:07 +02:00
Fabien Franzen
17c8576097
Save parent model of embedded relations
2015-04-01 16:59:21 +02:00
Fabien Franzen
aa5943f6b0
Properly support embedsMany destroyAll
2015-03-24 15:39:55 +01:00
Fabien Franzen
54781f376e
Enable custom methods on singular relations
2015-03-20 18:15:58 +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
Raymond Feng
a42e3b3d30
Add err checks
2015-02-20 21:14:48 -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
841f2d8f14
Tidy up tests so that they will work with RDBs
2015-02-20 16:10:25 -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
Miroslav Bajtoš
3593127ef3
Update to `should` to the latest version 4.6.3
2015-02-03 11:44:15 +01:00
Raymond Feng
1f0f4b0f02
Relax the id equality test for mongodb object ids
2015-02-02 10:51:41 -08:00
Raymond Feng
e46bd0cdb5
Fix hasOne remoting
2015-01-29 23:26:11 -08:00
Fabien Franzen
a08ef823be
Supply target to applyProperties function
2015-01-26 19:09:29 +01: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
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
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
Raymond Feng
73d022398a
Relax the id comparison
2014-12-08 16:18:42 -08:00
Clark Wang
9d2e6516c3
fix embedsOne error when embed instance is undefined or null
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-11-28 13:45:47 +08:00
Clark Wang
40f03f084b
fix recursive calls if create belongsTo model in beforeCreate hook
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-11-24 19:20:38 +08:00
Clark Wang
a9cc1c38df
Allow hasOne relation to have a scope option
...
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2014-11-20 19:27:04 +08:00
Raymond Feng
ba29669e0d
Merge branch 'fix/350-create-batch-hasmany-relation' of github.com:BuddyHOPP/loopback-datasource-juggler into BuddyHOPP-fix/350-create-batch-hasmany-relation
2014-11-13 12:50:21 -08:00
bitmage
d11eacffc6
handle relationship create with [array]
2014-11-11 14:48:34 -07:00
Alex Voitau
5c2468c4ef
#350 : Creating a batch via hasMany relation is failing. Added handling of array argument.
2014-11-07 18:01:18 -08:00
Alex Voitau
f1638e9e4c
#350 : Creating a batch via hasMany relation is failing. Added context 'with scope' to allow individual execution of tests.
2014-11-07 15:21:15 -08:00
Pandaiolo
833c24a2a3
Tests for non standard id - hasOne and polymorphic
2014-10-29 12:06:05 +01:00
Fabien Franzen
2838158139
Fix failing test
2014-10-09 18:18:04 +02:00
Fabien Franzen
ad55681d69
Properly reset Memory connector cache on automigrate
2014-10-09 18:13:58 +02:00
Raymond Feng
b5cebd75a7
Merge pull request #303 from khashayar/feature/test-improvement
...
Test improvement, shows _targetClass camelCase bug
2014-09-23 16:37:59 -07:00
Khashayar Hajian
28a661a81a
Test improvement, shows _targetClass camelCase bug
...
There is an issue where setting _targetClass on hasAndBelongsToMany
relations with a camel-case model name, fails.
Signed-off-by: Khashayar Hajian <me@khashayar.me>
2014-09-17 17:28:40 +02:00
Raymond Feng
3655107334
Merge pull request #295 from fabien/fix/embeds-many
...
Various improvements to embedded relations
2014-09-12 10:31:49 -07:00
Fabien Franzen
d1a08ef6b3
Add test case for Numeric ids (with optional forceId)
2014-09-07 20:54:11 +02:00
Fabien Franzen
e441924fa3
Allow embedsOne to use auto-generated id (from connector)
...
If the connector has a `generateId` method - like Transient - it can be
used to set the id (when the property has been set to `generated:
true`).
2014-09-07 13:24:05 +02:00
Fabien Franzen
21e1083e88
Implemented persistent: true option for embedsOne
2014-09-07 13:10:23 +02:00
Fabien Franzen
95764232b9
Introduce embedsMany persistent: true option
...
When set, instead of only embedding the model (on creation) it will be
persisted first, and subsequently embedded.
2014-09-07 12:59:47 +02:00
Fabien Franzen
ef816d490a
More tests for embedsMany with persistent model
2014-09-07 12:44:45 +02:00
Fabien Franzen
4c6f35d23d
Only check id as part of embedsMany relation
2014-09-07 12:17:42 +02:00
Fabien Franzen
a815ad0c1a
Test .value() method - as used by scope getter
2014-09-04 21:57:18 +02:00
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