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
See https://github.com/strongloop/loopback4-example-getting-started/pull/7/files#r150231004
app.repository(TodoRepository)binds the repository constructor asrepositories.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.namereturns 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 updateTodoRepository.nametoMyNewRepository.name.The only confusing part is that
@repositorysays the first string argument should be a model name. I think@repositoryshould allow repository name too and we should change the API and apidocs to support that.Loosely related: #745
Acceptance Criteria