loopbackio / loopbackio/loopback-next
Call repository function in static function.
Open
Nobody has claimed this yet.
bug
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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