Commit Graph

177 Commits

Author SHA1 Message Date
Siddhi Pai 3baa61590e Fix block padding
* Remove test/.eslintrc
* run eslint . --fix
2016-12-13 16:05:50 -08:00
Miroslav Bajtoš 0f7a567f18 Upgrade eslint & config to latest
- eslint ^3.11.1
 - eslint-config-loopback: ^6.0.0
 - fix linter errors (mostly no-undef)
2016-12-05 15:14:09 +01:00
jannyHou 6c8e806bc8 Apply hasManyThrough filter on target model 2016-12-01 10:08:27 -05:00
Loay 2cb0d042e4 Fix CI Failures in MySQL 2016-09-26 20:27:33 -04:00
Amir Jafarian aec678d252 Fix manually 2016-08-22 19:20:12 -04:00
Amir Jafarian aa6d28268b Auto-update by eslint --fix 2016-08-22 15:12:25 -04:00
Miroslav Bajtoš baec1b5b77 test/relation: add missing error handlers 2016-08-08 16:26:26 -04:00
jannyHou 8935b978f3 forceId=true with auto-increment db 2016-08-08 16:26:26 -04:00
Dimitris Halatsis ea2266e453 Persist changes on parent for embedsOne
Allow direct save of changes on embedded model to be persisted on
parent document.

    Person.embedsOne(Address);
    Person.findById(someId)
      .then(function(p){
        var address = p.addressItem();
        address.street = 'new street'
        // This will now persist changes on parent document
        return address.save();
      })

[forward-port of #949]
2016-06-07 17:24:59 +02:00
Dimitris Halatsis b7ba73f1b1 ModelBuilder: add new setting strictEmbeddedModels
The setting controls the strict mode used for embedded property types,
for example the type of "address" property in this model definition:

    modelBuilder.define('TestEmbedded', {
      name: 'string',
      address: {
        street: 'string',
      },
    });
2016-06-01 13:12:50 +02:00
Alex Pitigoi 0e89a9c837 fix avoid duplicate record on scope with promise 2016-05-19 15:47:31 -04:00
Miroslav Bajtoš c7f34c3452 eslint config 2.0 + remove extra empty lines
Upgrade eslint-config-loopback to ^2.0.0.

Remove extra empty lines to make `npm run lint` pass again.
2016-04-19 16:11:43 +02:00
Miroslav Bajtoš 27c6279d6c fix remaining eslint issues 2016-04-05 15:25:34 +02:00
Miroslav Bajtoš 39e04a1756 eslint --fix 2016-04-05 15:25:34 +02:00
Ryan Graham c467b43c38 Insert copyright headers 2016-04-04 18:14:03 -07:00
Raymond Feng d7bbd7e215 Fix the typo 2015-11-17 13:27:41 -08:00
mdartic ef7fe45d9c Rewrite of variable 2015-10-16 18:25:23 +02:00
mdartic 7c22db6ea7 Filtering relations of a model with an order specified 2015-10-16 18:21:04 +02:00
Raymond Feng 1e035c657e Fix the test so that it works across DBs 2015-09-11 11:15:00 -07:00
Raymond Feng a6519bb2ca Fix id comparision in tests so that they work with mongodb object id 2015-09-08 09:53:02 -07:00
sklyukin d0f9b760f5 primaryKey for hasMany and belongsTo relations 2015-09-01 19:03:02 +05:00
sklyukin 483cd873e7 primaryKey to hasOne relation 2015-09-01 01:31:28 +05:00
Raymond Feng 682f6340d3 Optimze automigrate() to cut the test time signicantly 2015-08-27 15:59:58 -07:00
ningsuhen 052e22ab43 Fix for issues #622 & #623
polymorphic hasOne needs separate handling and hasMany->referencesMany has a unique case which is fixed for MongoDB as suggested by @fabien.
2015-06-12 01:55:25 +05:30
mamboer 69bd7c1233 Merge remote-tracking branch 'upstream/master' 2015-05-26 12:28:11 +08:00
Raymond Feng eac74ad014 Make sure relation scope is applied during include 2015-05-16 11:49:02 -07:00
mamboer 5ff3798e8e enhancement on #588 2015-05-14 09:55:54 +08:00
mamboer d27b2eb25f fix issue #587 2015-05-13 13:18:50 +08:00
Raymond Feng 33bbd8634c Fix the test cases 2015-04-24 16:50:15 -07:00
ningsuhen 7861c08e5a add test case for hasmanythrough bi-drectional relations 2015-04-25 01:32:33 +05:30
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