Commit Graph

1480 Commits

Author SHA1 Message Date
Raymond Feng 2b4b44292a Fix tests to ensure compatibility w/ should@10 2018-05-24 14:21:12 -07:00
Raymond Feng 5a66f9ad72 Fix datasource state management
Use case:
1. Configure a datasource with lazyConnect = true
2. Do NOT start the DB
3. Start the app
4. Send first request and it fails to connnect to the DB
5. Start the DB
5. Requests are now served correctly
2018-05-22 10:46:45 -07:00
Raymond Feng 90163ba709 Allow toObject() to accept an 'options' argument 2018-05-10 10:18:55 -07:00
Raymond Feng cc99cd8f0f Tidy up datasource 2018-05-03 14:14:53 -07:00
Miroslav Bajtoš f8479253fa
Polyfill Number.isFinite() to support PhantomJS 2018-04-17 10:08:39 +02:00
Miroslav Bajtoš 5af4c42728
feat: remove a Model from all registries
Add API allowing consumers (e.g. LoopBack) to remove a Model from all
juggler registries:
 - ModelBuilder's models
 - ModelBuilder's definitions
 - Connector registry of models
2018-04-16 14:24:53 +02:00
Janny 01427b1755 feat: omit default fn for embedsMany (#1532)
* feat: omit default fn for embeds many

* fix: apply feedback
2018-04-13 13:17:40 -04:00
bmatson c3e502032e
Pass options argument to custom validators 2018-03-22 15:51:21 +01:00
Raymond Feng 87e1e217c3 fix: allow `new DataSource(connector, settings)` 2018-02-13 09:42:41 -08:00
Raymond Feng 4be2ea8afb fix: add more tests to verify new DataSource() 2018-02-09 14:33:42 -08:00
Raymond Feng 9d3e6cd8f5 Merge branch 'set-datasource-name' of https://github.com/truongminh/loopback-datasource-juggler into truongminh-set-datasource-name 2018-02-07 16:50:57 -08:00
Nguyen Truong Minh 80f9364edc feat(datasource): seperate name and connector name 2018-02-07 16:25:25 +07:00
Kevin Scroggins 25b1aa5abc Fix datasource not correctly retaining name value 2018-01-31 11:30:24 -05:00
Miroslav Bajtoš 309b422425
Merge pull request #1542 from nitro404/hotfix/datasource-name-mismatch-warning
Add warning for datasources with mismatched names
2018-01-25 07:57:25 +01:00
Kevin Scroggins 07f0310d34 Added error handling for persist operation hook (#1531)
Unrelated CI failures. -.-
2018-01-24 11:37:30 -05:00
Kevin Scroggins 92595b4348
Add warning for datasources with mismatched names 2018-01-23 14:18:49 +01:00
Taranveer Virk cc60ef8202 fix unauthorized fk change (#1538)
Downstream failures are unrelated.
2018-01-17 13:34:37 -05:00
Miroslav Bajtoš b0b377af0c
Set model constructor name to model name
Rework the code building model constructors to leverage `Function` class
and dynamically emit a constructor function named after the model.

Before this change, all model classes were called "ModelConstructor",
which made debugging difficult.

After this change, a model class for model "User" is called "User.

Because not all valid model names are also valid JavaScript identifiers,
we implement a simple sanitization technique (replacing characters like
"-", "." and ":" with underscore "_") and fall back to legacy
"ModelConstructor" if the model name is still not a valid JS identifier.
2018-01-08 09:37:23 +01:00
zbarbuto f5de99b249 Allow new transaction method in postgresql (#1493)
kv-extreme-scale needs fixing, unrelated.
2017-12-12 10:56:42 -05:00
Peter Bouda 6bd9fca080 Fix bug in utils uniq function (#1526)
The uniq function does currently not work when the database is mongodb.
In the case of mongodb, the function will receive an array of bson
object of bson type ObjectID. The indexOf function will return a
different index, even if the mongodb ID is the same, as it is wrapped
in the ObjectID. This commit first transforms any ObjectID in the array
to a string representation. We can then use indexOf to check for
uniqueness.
2017-12-04 15:39:58 -05:00
Joost de Bruijn 7a4c6ca2f9 Fix query for related models (#1522) 2017-11-14 14:22:48 -05:00
zbarbuto 1d8603c491 Allow customizing embedded relation property (#1513) 2017-10-31 10:55:54 -04:00
Zak Barbuto 99cea38fd0 Allow passing null to base model ctor 2017-09-28 09:42:30 +09:30
Jürg Lehni 0ce1fa9f87 Add a better way to handle transactions 2017-09-06 07:10:57 +02:00
Joost de Bruijn f18d3487c6 validations: use new regex per evaluation (#1479)
The RegExp is cloned before executing the test. Fixing issue #1475.
2017-09-01 12:48:29 -04:00
Jürg Lehni 94a602d17e Transaction: Bind timeout to tx instance (#1484) 2017-08-31 11:10:17 -04:00
Rashmi Hunt 6c6df15286 Flag id as updateOnly when forceId is in effect (#1453)
* updateOnly, forceId changes

* support getUpdateOnlyProperties

* fixup! fix updateOrCreate in forceId mode

The contract of `updateOrCreate` is expecting a full object instance
to be passed to the callback.

The current implementation was creating an empty instance and
calling updateAttributes under the hood. As a result, the callback
was called with the attributes being updated only.

In order to preserve existing behaviour, we have to always build
a full initial instance by calling `findById`.

See the following discussion for more context:
https://github.com/strongloop/loopback-datasource-juggler/issues/966

* fixup! fix tests of upsert validation

* move forceId to model-builder

* remove TODO comment

* revert refactoring and test fixes

* Remove duplicate test

* change testcase names

* change to ModeClass.settingse

* forceId setup from datasource to model-builder

* fix inheritance of auto-generated forceId

* Fixed failing tests for auto change

* fixed a comment
2017-08-22 13:09:45 -07:00
loay 01b4c4a3a7 Catch err using Callback 2017-08-16 17:00:41 -04:00
Loay 80f3e93367 Merge pull request #1416 from strongloop/feature/fix-2364
Fix undefined properties in where
2017-08-09 13:54:28 -04:00
Tom Kirkpatrick 138b99c703 fix: support numbers in validatesFormatOf
Fix for #1437
2017-08-03 14:47:11 -04:00
Raymond Feng 03753b6fe2 Fix undefined properties in where
https://github.com/strongloop/loopback/issues/2364
2017-08-03 14:09:21 -04:00
ssh24 80f015c2d2 Honor backwards compatability with validate update 2017-08-03 11:50:44 -04:00
ssh24 9cd0108fc6 Fix update validation callback 2017-08-02 14:55:47 -04:00
ssh24 b1a0cb8c3b Validate updateAll 2017-08-02 13:24:21 -04:00
dmellonch 1b7c346bca Missing the option argument (#1426)
* Fix missing option arguments in scope.js

Added option arguments in find.relatedmodel
Added case test

* Add order filter in verify function

Fix for cloudant test
2017-08-01 14:15:21 -04:00
loay b1b2d5df0c Catch errors using cb 2017-07-24 14:08:58 -04:00
Diana Lau ff9b25a905 Merge pull request #1432 from simoami/master
#1386 Allow empty values when allowBlank is true
2017-07-20 11:23:54 -04:00
Jürg Lehni 4c9e91423f
Rename getAsync() methods to find() and get()
Keep getAsync() around for backward compatibility, but deprecate it
2017-07-20 14:48:29 +02:00
Simo Moujami 82a8e3d9a1 #1386 Allow empty values when allowBlank is true 2017-07-19 19:26:13 -04:00
Tetsuo Seto 4a6f0a4aa0 Fix the case where qWhere[idKey] is null 2017-06-09 09:33:22 -07:00
ssh24 98174251f1 Fix mixins/validatable docs 2017-06-06 14:21:49 -04:00
ssh24 ba1901b2a0 Fix updateAttributes cb
Allow pass through of the new data from the connector
Specifically for cloudant since updateAttributes changes the _rev
2017-05-29 15:32:32 -04:00
Rand McKinney 0a056adee4 Remove spurious extra options arg (#1390)
* Remove spurious extra options arg

* Remove space
2017-05-26 11:34:50 -07:00
Kevin Delisle 1b625228b9 include: remove JSDoc refs to recursive calls 2017-05-24 17:10:45 -04:00
Kevin Delisle d058244594 hooks: add JSDoc for .trigger 2017-05-23 12:12:11 -04:00
Kevin Delisle 117152d090 model-builder: JSDoc tidy-up 2017-05-23 10:31:38 -04:00
Raymond Feng 5a0b0270f3 Return promise for batch create 2017-05-19 16:16:52 -07:00
ssh24 54f67dc3b0 Use correct data on replace callback
Previously, it would just pass the old data
Pass the new data as cloudant updates the _rev property on CRUD
2017-05-18 17:03:21 -04:00
Raymond Feng c41487a1d1 Merge pull request #1371 from strongloop/exclude_prop
Handle excludeBaseProperties
2017-05-15 11:06:27 -05:00
Tetsuo Seto c07f46000d Support include rework for C* connector
- Remove supportNonPrimaryKeyIN
- Add C* Uuid in build call
- Implement smartMerge in scope.js
2017-05-12 22:43:21 -07:00