-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
See https://github.com/strongloop/loopback4-example-getting-started/pull/7/files#r150231004
export class TodoController {
constructor(@repository(TodoRepository.name) protected todoRepo: TodoRepository) {}
// ...
}app.repository(TodoRepository) binds the repository constructor as repositories.TodoRepository, thus this line could have been changed to @repository('TodoRepository'). However, I'd like to avoid string constants because don't follow "refactor - rename" changes. TodoRepository.name returns the string name of the repository we want to inject. If we decide to rename the repository class to something else, then refactoring tools will update TodoRepository.name to MyNewRepository.name.
The only confusing part is that @repository says the first string argument should be a model name. I think @repository should allow repository name too and we should change the API and apidocs to support that.
Loosely related: #745
Acceptance Criteria
- Update the argument name and corresponding TSDoc to allow either the repository name or the model name.
- Update example packages in monorepo
- Update loopback.io docs accordingly