Is it possible to use MongoDB in a worker?
Hey,
I want to use MongoDB as my db, but I read that the nodejs mongodb driver uses websockets to connect to mongodb which isn't viable in a worker,
I read that it's possible to use Atlas mongodb Data/HTTP API but it seems that it is deprecated, is there a proper way to user mongodb in a worker?
Thanks.
4 Replies
Yes, it is possible to use
you need to set up your own API layer that acts as a bridge between your MongoDB database and Workers.
Yeah, but that API layer would have to be a regular node service or something similar and won't run on the edge, I meant is it possible to connect to mongo directly from the worker
I think it is impossible to connect directly because MongoDB typically requires a TCP connection, and Workers don't support persistent connections like TCP, WebSockets
it is possible now within a worker,
as workers support NET