Using $function to run a javascript function is not working in mongosh

Hi @Luis_Leon - Welcome to the community :wave:

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.

Can you try running the aggregation below?:

db.movies.aggregate([
  {
    '$addFields': {
      fromFunction: { '$function': { body: function(){return 'hello'}, args: [], lang: 'js' } }
    }
  }
])

If nothing is returned, can you advise the output of db.movies.countDocuments()?

Regards,
Jason