Commit Graph

1520 Commits

Author SHA1 Message Date
biniam 9c94b9344b fix: allow coercion of nested properties
Handle model definitions with nested property
definitions for coercion of primitive values.
2019-05-03 18:45:39 -04:00
Miroslav Bajtoš 5c3405eceb
Add support for Node.js 12.x
- Fix code to pass all tests on Node.js 12
- Add Node.js 12 to the list of Travis CI platforms
2019-04-29 09:46:57 +02:00
biniam 48af738ec4 fix: coerce primitive properties on update 2019-04-16 10:51:44 -04:00
biniam 1534392c62 fix: coerce date array properties 2019-04-16 10:50:54 -04:00
spurreiter 55b10a43c4 fix: normalize include with boolean or number
- On include = true or include = 1 the lib crashes with
  "TypeError: includes.forEach is not a function".
- checking for boolean and number type and return empty array.
- fix: include symbol and function in normalization
- fix: review changes; adding debug stmt + early exit for tests
2019-04-05 19:02:57 +02:00
Miroslav Bajtoš e45292de08
Do not apply default values on data from database
Before this change, when a property was configured with a default value
at LoopBack side and the database was returned a record with a missing
value for such property, then we would supply use the configured
default.

This behavior is problematic for reasons explained in #1692.

In this commit, we are fixing DAO operations like `find` and
`findOrCreate` so that they do NOT apply default property values on
data returned by the database (connector).

Please note that most of the other CRUD methods were already not
applying default values on database data as long as the connector
provided native implementation of the operation.
2019-04-04 09:47:31 +02:00
Hage Yaapa 80d8fcd8b1 feat: support array within array 2019-03-07 15:58:26 +05:30
Hage Yaapa a391c83a2c feat: Support "type" key in sub-properties 2019-02-21 13:58:34 +05:30
biniam 5e0c73bec7 fix: use correct callback for geo find queries 2019-02-14 15:45:13 -05:00
Miroslav Bajtoš fd99c6dc6e
Support nested properties with class type
When converting plain-data object values into model instances,
correctly handle the case where the constructor functions is a class
constructor and must be invoked via `new`.
2019-01-25 10:05:36 +01:00
Miroslav Bajtoš 9e0f624ad5
manually fix remaining problems 2018-12-07 16:46:15 +01:00
Miroslav Bajtoš 422ec9ad4f
autofix eslint errors 2018-12-07 16:46:15 +01:00
Miroslav Bajtoš 84322d07a9
Update eslint-config-loopback to latest 2018-12-07 16:22:59 +01:00
Miroslav Bajtoš e834368502
Upgrade bson to 4.x (latest) 2018-12-07 16:22:59 +01:00
Miroslav Bajtoš fda332d60b
feat: dataSource.execute(cmd, args, opts, cb)
Implement a new helper API for calling connector's "execute" method
in a promise-friendly way.
2018-12-07 14:51:14 +01:00
Raymond Feng f9131aa18f Use options from request for settings 2018-11-13 12:32:55 -08:00
Raymond Feng f6e1df87be Allow flags to be passed via options 2018-11-09 09:33:05 -08:00
leon3s 65548b6fe0 [ BUGFIX ] maxDepthOfQuery config 2018-11-06 17:29:14 +01:00
Raymond Feng eb85b3e3a6 Allow configuration of maxDepthOfQuery
https://github.com/strongloop/loopback-datasource-juggler/issues/1651
2018-10-31 08:45:16 -07:00
Raymond Feng dbe25f282d Check composite keys containing hidden props 2018-10-29 07:57:55 -07:00
Raymond Feng 8fa7c94605 Improve hidden/protected property checks
- Fixes #1645
  - do not apply hidden property check for data
- Fixes #1648
  - allow prohibitHiddenPropertiesInQuery to be set in model/ds
2018-10-28 10:03:12 -07:00
Raymond Feng 2af2599a7d Allow hidden/protected props as an object
Fixes #1646
2018-10-27 07:51:34 -07:00
Raymond Feng a391762771 Ren handleUndefined to normalizeUndefinedInQuery 2018-10-26 09:09:50 -07:00
Raymond Feng 0ce3f4ead9 Report circular or deep query objects 2018-10-25 15:14:20 -07:00
Raymond Feng 39ff54d392 Hide offending properties from the error object 2018-10-25 15:14:20 -07:00
Raymond Feng a761e0d114 Tidy up extended operator check 2018-10-25 15:14:14 -07:00
Raymond Feng f2e718639a Prevent hidden/protected props from being searched
- report errors if where contains hidden properties
- report errors if incldue scope contains hidden or protected properties
2018-10-19 09:25:47 -07:00
Raymond Feng 60e16298f2 Report errors for missing id props for include
https://github.com/strongloop/loopback/issues/4028
2018-10-19 09:20:12 -07:00
Raymond Feng f7036b2837
Merge pull request #1629 from mgabeler-lee-6rs/fix/fast-id-unique-check
fix: accelerate unique id checking
2018-10-14 07:58:35 -07:00
Miroslav Bajtoš abaf29f74d
Merge pull request #1623 from mitsos1os/issue-1622
Fix patchAttributes for embedded document properties in MongoDB
2018-10-09 14:55:56 +02:00
Miroslav Bajtoš b6a43dd65a
Switch from Bluebird to native Promise
This is a breaking change. Juggler methods are no longer returning
instances of Bluebird Promise, but return a native Promise instead.

As a result, API consumers can no longer use sugar APIs provided by
Bluebird, e.g. `spread`, `delay`, etc.

Migration guide: rewrite your code from `.then()` style into `async`
functions using `await` statements.
2018-10-05 09:30:02 +02:00
Matthew Gabeler-Lee 1ddac5bddb
fix: add test coverage, correct typo that exposed 2018-10-03 18:56:57 -04:00
Matthew Gabeler-Lee 248d57da4e
fix: accelerate unique id checking 2018-10-03 18:40:42 -04:00
Dimitris eb921ed9d5 remove null in embedded doc properties updates
calling patchAttributes without all embedded properties inits to null
2018-09-24 10:04:09 +03:00
Raymond Feng 7eec7e4e34 Allow List to take items as instances of a class 2018-09-17 08:22:21 -07:00
Tom Kirkpatrick 251798c711 fix: ignore extra properties when strict=filter (#1423)
Fix for #1422
2018-08-29 22:57:37 -04:00
Miroslav Bajtoš 7d50f6130b
Upgrade eslint-config-loopback + fix formatting
The new version of our config enabled function-paren-newline rule,
this commit fixes the codebase to use more consistent handling
of newlines when calling functions.
2018-07-16 08:46:25 +02:00
virkt25 9bd7f8d02f
fix: regression on Operation Hooks
Fix the regression introduced by 9af79cf51a where updateAttributes
and replaceAttributes was incorrectly handling the response returned
by the database.

This commit restores the old behaviour where `context.data` is updated
only by a connector-provided function and reverts an incorrect change
of a test file made as part of the faulty fix.

Besides the fixes, this patch also renames `data` to `dbResponse` and
add comments explaining the structure of the response object for more
clarity.
2018-07-09 16:41:56 +02:00
Miroslav Bajtoš 9af79cf51a
Fix Operation Hooks to propagate data changes
Before this change, many Operation Hooks were not correctly propagating
changes made to `ctx.data` via reassigning ctx.data to a new object.

This change modifies existing tests to account for this different
scenario, adds few more tests for scenarios that were not covered by
tests before and finally fixes the problem discovered.
2018-06-28 12:22:16 +02:00
Miroslav Bajtoš d2ee73b9d3
Update eslint + config to latest 2018-06-12 09:13:32 +02:00
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