title: MongoDB create user dependent view/pipeline
body: <p>I just stumbled over views in MongoDB and was wondering, if it is in principle possible to create a user depedent view. For example, his user setting from a User_Settings collection.</p>
  <p>For the view I came up with the following code, which works fine, as long as the user name is known beforehand:</p>
  <pre><code>[
     { 
          &quot;$match&quot; :
          { 
              &quot;name&quot; : &quot;test&quot;
          }
      }
  ], 
  { 
      &quot;allowDiskUse&quot; : false
  }
  </code></pre>
  <p>The current user name is accessible by:</p>
  <pre><code>var currentUser = db.runCommand({connectionStatus: 1}).authInfo.authenticatedUsers[0].user
  </code></pre>
  <p>But I could not manage to find out how to merge those two into a coherent view definition. I tried like so, which is obiously not working:</p>
  <pre><code>    &quot;$let&quot; :
      {
          vars: {currentUser: {connectionStatus: 1}},
          in: {connectionStatus: 1}
      }
      { 
          &quot;$match&quot; :
          { 
              &quot;name&quot; : currentUser
          }
      }
  ], 
  { 
      &quot;allowDiskUse&quot; : false
  }
  </code></pre>
  <p>Is this at all possible? If so, I would be very grateful if somebody could provide an example.</p>
  <p>Thank you</p>