There is no specific object for this. One thing you could do is run part of this code in the mongo shell, which can execute exactly the same javascript as the server. There is no debugger in the shell, but with its interactive prompt it would be much easier to try things, check variables, etc.
Personally, I would not recommend moving the code to the server. Please note that you can send several write operations (for example, inserts) on one line, and then after sending to several, request one confirmation. Thus, this scenario is not necessarily slow, even if there is nontrivial latency of the network.
Alternatively, you can run C # code on the same server as the mongod process, and thus get an extremely low latency when processing requests. One way to do this is to make a web server written in C # and encapsulate the logic suggested above.
source share