-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: update model decorator #3354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| ## LB4 vs. LB3 | ||
|
|
||
| ### How LoopBack 4 creates/handles models. [2019 July 24] | ||
|
|
||
| In `lb4`, we introduce the concept of | ||
| [`repository`](https://loopback.io/doc/en/lb4/Repositories.html). In order to | ||
| implement this new feature `repository`, we are using legacy juggler bridge as a | ||
| (temporary) solution. Each model has two **parallel classes**: | ||
|
|
||
| - The class defined by the app developers using decorators and | ||
| `class MyModel extends Entity` syntax. | ||
| - The "implementation" class created by legacy-juggler-bridge, this class is | ||
| inheriting from juggler's Model `base class`. | ||
|
|
||
| If you take a deep look into it, you would find that LB4 model handles some data | ||
| before it hands the model to Juggler. That's why `lb4` has some differences | ||
| compared to `lb3` when generating models. | ||
|
|
||
| For example, you might notice that some entries in `@model` decorator are not | ||
| available/supported by lb4 even they both run the same lines of code in Juggler. | ||
| For instance, the default values for the `strict` entry in `@model decorator` | ||
| are different: | ||
|
|
||
| | | [in LB3](https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html#top-level-properties) | [in LB4](https://loopback.io/doc/en/lb4/Model.html#model-decorator) | | ||
| | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `default` | `false` | `true` | | ||
| | code | [defined here](https://github.com/strongloop/loopback-datasource-juggler/blob/2b8c1ebaeec3d8be87da38236db3d8210bca6230/lib/model-builder.js#L130) | [defined here](https://github.com/strongloop/loopback-next/blob/ba3f3894ef7e102b0fcd8b9b7a1f1d221bbbf4a4/packages/repository/src/repositories/legacy-juggler-bridge.ts#L160) | | ||
|
|
||
| Hope this example shows the idea that even they both use the `base model` from | ||
| Juggler, LB4 model doesn't use, or even have access to some fields/entries in | ||
| the Juggler model! | ||
|
|
||
| As mentioned before, we are using the legacy juggler bridge as a temporary | ||
| solution. This may change in the future since the Juggler is pretty.. you know, | ||
| legacy. However, it's important to realize how LB4 deals with models. | ||
|
|
||
| Happy coding :D |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.