Hi all. I’m trying to use a function in order to parse a json format field in a collection. But it seems that I’m missing some previous steps in order to do so, if I run a simple aggregation like this:
nothing happens, the collection is not created ( Reference: How to Use Custom Aggregation Expressions in MongoDB 4.4 | MongoDB).
Do I need to install any driver or package, or setup the shell in order to run such javascript function? I’m using MongoDB Compass Shell. Versions: MongoDB Compass 1.36.4, mongoDB 6.0.6
I presume you’re expecting it to return a document with an additional field called fromFunction with the value 'hello' - please correct me if I’m wrong here.
Hello Jason, thanks for your reply. I tried running your aggregation, but it justs hangs and the prompt is not returned. By the way, when I tried running a function using JSON.parse it behave the same way, it just hanged, that’s why I tried running a simpler function in order to see if the shell configuration was Ok.
Additionally, when you state the prompt hangs, do you mean that the test> indicator in the embedded mongoshell in compass is not returned and you cannot type further?
Step 3, again the prompt hangs, with that I mean that the test indicator in the embedded mongoshell never returns, the only way to quit is closing Compass window and start again, like picture below:
Am I missing some driver or software installation in order to run a javascript function?
I was able to replicate the prompt hanging in the embedded mongosh shell in Compass. It does work from the standalone mongosh so if you’re able to try that in the mean time hopefully it works for you.
Good news is javascript function is running ok now using standalone shell. Now the problem is different, but I think I will open a new topic. Thanks Jason