title: using $function new operator in MongoDB for updateMany failed
body: <p>I have an array tree and I want to update that array in my collection with this syntax</p>
  <pre><code>db.documents.updateMany(
    {
      companyId: ObjectId(&quot;5f29074048538b6403bc71ab&quot;,
      tree: {
        $in: [ObjectId(&quot;5f539bf696fa1748fa417b07&quot;)],
      },
    },
    [{
      $set: {
        tree: {
          $function: {
            body:
              &quot;function(t) { t.push(ObjectId('5f5494a1d708bda4988d75d4')); return t.filter(v =&gt; [ObjectId('5f539bf696fa1748fa417b07')].includes(v))}}&quot;,
            args: [&quot;$tree&quot;],
            lang: &quot;js&quot;,
          },
        },
      },
    }]
  );
  
  </code></pre>
  <p>why I write body function with string? because in Golang I can't use code for bson, so I must use function string, the syntax above is I run on command line mongo cli to try there first then implement to my Go app</p>
  <p>the error I got is</p>
  <pre><code>Unrecognized expression '$function'
  </code></pre>
  <p>anyone has same problem ? or I did wrong to use <code>$function</code> operator ??</p>