Commit Graph

1511 Commits

Author SHA1 Message Date
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
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