I searched many answers through google, but all suggestions are to install mongodb through npm. Then i tried to analyze MongoDB Node.js Driver source code, where are mongodb library. And found that it seems to be implemented through nodejs's native net module. Can someone give me some pointers, thank you for your suggestions.

1

There are 1 best solutions below

1
On BEST ANSWER

You can connect to mongod/mongos's ports using your favorite socket library and speak the raw protocol directly. The handshake is described here. OP_MSG which is used with 3.6 and newer servers is described here. See also this. You may need to read some driver source to figure out how to attach everything together (for example, the messages need to be serialized to bson for transmission over the wire).