loopbackio / loopbackio/loopback-next
Call repository function in static function.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
I need user list in static function of controller.
```
export class NotificationController {
constructor(
@repository(UserRepository) public userRepository: UserRepository,
) {
}
public static async sendPushNotification(userId: string) {
const userInfo = await userRepository.findById(userId, {fields: ['pushToken']});
// send push code
}
}
```
But I can not use userRepository and call repository function.
Is there solution for this?
### Logs
_No response_
### Additional information
_No response_
### Reproduction
I write code
Contributor guide
Research direction
Start with the NotificationController example and the injected UserRepository usage shown in the issue. Determine whether static controller methods are expected to receive repository dependencies; done means confirming and documenting a supported way to access UserRepository from sendPushNotification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100