Created
April 1, 2025 08:44
-
-
Save dunklesToast/4470718d169e24337d20cff20ff3146d to your computer and use it in GitHub Desktop.
small example of how to use mikroorm's CreateRequestContext decorator with queues in NestJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
@Processor('processor') | |
export class Processor { | |
constructor( | |
private readonly service: Service, | |
// this is needed for the CreateRequestContext decorators | |
private readonly orm: MikroORM, | |
private entityManager: EntityManager, | |
) {} | |
@CreateRequestContext() | |
private doSomethingOnTheDatabase(id: string) { | |
return this.service.findSomethingFromDatabase(id); | |
} | |
@Process() | |
async generate(job: Job) { | |
await this.doSomethingOnTheDatabase(job.data.resourceId); | |
return {}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment