Commit Graph

175 Commits

Author SHA1 Message Date
jannyHou 9a5bd51db5
feat: omit default fn for embeds many 2018-07-30 12:54:51 +02:00
Taranveer Virk 2167e802a9
fix unauthorized fk change (#1540) 2018-01-19 12:48:56 -05:00
Janny 6d017c1e34 Fix #1079 - Polymorphic hasMany inverse relation (#1296)
This fixes the polymorphic hasMany inverse relation
not working as expected in include filters.
2017-07-11 15:47:32 -04:00
Janny 2190f2510f Backport - Apply hasManyThrough filter on target model (#1404)
* Apply hasManyThrough filter on target model

* Compatible with mongodb
2017-06-22 16:51:10 -04:00
Brian Schemp d87e3bf8fb Throw error when model relation name is trigger
Defining a model relation with the name "trigger" causes the model not
able to insert records. No error is thrown when a model relation with
the name "trigger" is defined. Adding a check for the model relation
name "trigger" will now throw an error.
2017-01-03 10:41:07 +01:00
Amir Jafarian e038b28e8c Fix manually 2016-10-19 17:35:26 -04:00
Amir Jafarian a1683fca59 Auto-update by eslint --fix 2016-10-19 17:04:05 -04:00
Dimitris Halatsis af8cf19242 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();
      })
2016-06-07 17:09:34 +02:00
Dimitris Halatsis 39907c6421 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',
      },
    });

[back-port of #955]
2016-06-01 13:42:55 +02:00
Simon Ho 65d6d6a508 Backport ESLint from master 2016-05-20 17:35:23 +02:00
Miroslav Bajtoš 289eac7565 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.

[back-port of #909]
2016-04-19 17:06:04 +02:00
Miroslav Bajtoš a5187765f6 Run `eslint --fix` with config from master 2016-04-18 16:00:04 +02:00
Miroslav Bajtoš 093a69328c Insert copyright headers 2016-04-06 16:51:49 +02: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
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