Skip to content
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

docs: dynamic models, repositories, and controllers #5591

Merged
merged 1 commit into from
May 29, 2020
Merged

Conversation

hacksparrow
Copy link
Contributor

Addresses #4296.

How to dynamically add models, repositories, and controllers during
runtime.

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@@ -254,6 +254,10 @@ children:
url: Serving-static-files.html
output: 'web, pdf'

- title: 'Dynamic models, repositories, and controllers'
url: Dynamic-models-repositories-controllers.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing indent. I think this .yml needs to have the right indentation in order for it to work.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start 👏

Cross-posting #4296 (comment):

Instead of creating a new doc page, update existing doc pages for DataSources, Models to describe different ways for creating the artifacts.

It would not be fun having to guess and search through the docs find out how to dynamically add models and controllers. However, I agree we should update those pages as well.

Can you please update the pages listed in #4296 (comment) to mention the different ways how a Model/Repository/Controller can be created?

  • Using our CLI to create them as static artifacts in source code files.
  • Using lb4 rest-api to build the repository & controller dynamically at runtime using the user-provided config.
  • And finally the fully dynamic approach you are describing here.

docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
docs/site/Dynamic-models-repositories-controllers.md Outdated Show resolved Hide resolved
@hacksparrow
Copy link
Contributor Author

Can you please update the pages listed in #4296 (comment) to mention the different ways how a Model/Repository/Controller can be created?

Shall we do it in a separate PR?

I have applied all your feedback. Thanks a lot @bajtos.

@bajtos
Copy link
Member

bajtos commented May 29, 2020

Shall we do it in a separate PR?

I am fine either way, as long as the changes are made as part of #4296 in the next few days.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏

Please get approvals from other people that commented on this PR before landing.

Create a repository mixin with your customization as shown in the
"
[Defining A Repository Mixin Class Factory Function](https://loopback.io/doc/en/lb4/migration-models-mixins.html#defining-a-repository-mixin-class-factory-function)
" example, and then specify this repository as the base class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" example, and then specify this repository as the base class.
" example, apply the mixin on the base repository class (e.g. `DefaultCrudRepository`) then specify this combined repository as the base class to be used.

@hacksparrow
Copy link
Contributor Author

I am fine either way, as long as the changes are made as part of #4296 in the next few days.

Sure.

@hacksparrow hacksparrow force-pushed the doc/dynamic branch 2 times, most recently from d87b0c6 to 0c3239b Compare May 29, 2020 15:31
Copy link
Member

@dhmlau dhmlau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Other than that, LGTM.

@@ -254,6 +254,10 @@ children:
url: Serving-static-files.html
output: 'web, pdf'

- title: 'Dynamic models, repositories, and controllers'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe Dynamically adding models, repositories, and controllers? to match the title of the docs page.

@@ -0,0 +1,259 @@
---
lang: en
title: 'Dynamically add models, repositories, and controllers during runtime'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: 'Dynamically add models, repositories, and controllers during runtime'
title: 'Dynamically adding models, repositories, and controllers during runtime'

How to dynamically add models, repositories, and controllers during
runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants