-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use TypeORM or Prisma inside worker ? #392
Comments
If this is a question about TypeORM please ask at the project itself. You can ask questions here about |
It's about workerpool, i want to find a way to use Async methods inside workerpool, like typeorm's async methods, it's just an example |
You can "just" use async functions and return Promise like results. Here is an example: https://jsbin.com/semafew/edit?html,console |
Here is the problem i have with the same code: import workerpool from "workerpool";
import { User } from "./entities/User";
export const queues = workerpool.pool({
maxWorkers: require("os").cpus().length,
});
async function getUsers() {
function getResults() {
return new Promise(async (resolve, reject) => {
resolve(await User.find());
});
}
return await getResults();
}
const test = await queues.exec(getUsers, []);
|
The function |
Is there a way to call the dedicated worker with a class name ?
Thanks for the solutions |
No, just like a regular |
Hey,
I'm using TypeORM.
How i can use "await" inside .exec() function ?
I want to wait for the results from my database inside a worker.
The text was updated successfully, but these errors were encountered: