-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(cli): bind model classes during boot #5378
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
Conversation
achrinza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This is useful for context inspection to know what model classes are in an application.
|
I need it in my project that I use, please review it as soon as you can thanks! :) |
hacksparrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from that debug message, it LGTM.
|
|
||
| debug('Bind class: %s', cls.name); | ||
| // We are binding the model class itself | ||
| const binding = this.app.bind(`models.${cls.name}`).to(cls).tag('model'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raymondfeng can you please extract the code building the binding to a standalone function that can be used to bind models manually, in cases where @loopback/boot is not involved? For example in extensions.
const binding = createModelClassBinding(cls);
app.add(binding);Similar helpers we already have: createComponentApplicationBooterBinding, createBindingFromClass, createBodyParserBinding, createServiceBinding.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈