title: Mongo error: "$out stage requires a string argument, but found object (code: 14, codeName: TypeMismatch)"
body: <p>I'm trying to write a Mongo aggregation using the <a href="https://docs.mongodb.com/master/reference/operator/aggregation/out/#examples" rel="nofollow noreferrer">out operator as described in the docs.</a> This is the aggregation I'm writing:</p>
  
  <pre><code>db.mycollectionname.aggregate([
      { $match: {} },
      { $project: {}},
      { $out: {to: "projets", mode: "insertDocuments"}}
  ])
  </code></pre>
  
  <p>When I execute this I get the following error: <strong>$out stage requires a string argument, but found object</strong> - clear in and of itself but it goes against what the docs say. When I provide a string to the $out stage, I don't get the error but that's not what I want.</p>
  
  <p><a href="https://i.stack.imgur.com/LalpD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LalpD.png" alt="executed from the terminal and from Studio3T."></a></p>
  
  <p>Mongo version: 3.6.9</p>
  
  <p>(I have more logic under the $project pipeline stage which I removed for brevity, it doesn't have any impact).</p>
  
  <p>Can someone help me understand why this differs from what the docs say? And how I can provide the arguments I want to pass to the out stage (an object containing "to" and "mode") as a string?</p>
  
  <p>Many thanks,</p>
  
  <p>Chris.</p>