title: Specific document for every user
body: <p>I'm new in MongoDB and I just can not understand how the database works to the end. For a start, I'll explain what I want to do. It is necessary to make a form on the site through which new users will be added for the client program on WPF.NET in which the connection to the server will occur.</p>
  
  <p><strong>It is not clear to me where the user should be in the database</strong> in admin or in my database, what is it local, config dbs?</p>
  
  <p>I watched the video and read for the <em>authentification</em>. Okay, I created the user, but it connects to the whole database, and so can read the data of another user. I mean that if someone wants to go to the server and hack into or overwrite the data of another client. <strong>Is it possible to give the client access to only a specific document?</strong></p>
  
  <p>Example:<br>
     <strong>Users</strong>: <strong>ClientUser1</strong>, ClientUser2, ClientUser3<br>
     <strong>Collection ClientCollection</strong>: <strong>Document1ForUser1Only</strong>, Document2ForUser2Only, Document3ForUser3Only</p>
  
  <p>C# WPF .NET Client I Call<br>
  new MongoClient("mongodb://127.0.0.1:27017/?db=custom&amp;user=<strong>ClientUser1</strong>&amp;password=1234"<br>
  <em>Access only for <strong>Document1ForUser1Only</strong>, because is it correct user account data.</em></p>
  
  <p><strong>Update1</strong><br>
  It seems to me that all this can be done through roles. I did my part and pointed it to the user. But when I do a search for my collections, it shows me a mistake. And in the program Studio 3T I do not see any collection.</p>
  
  <pre><code>db.createRole({ role: "User",
    privileges: [
      { resource: { db: "testdb", collection: "UserCollection" }, actions: [ "find", "update", "insert", "remove" ]}
    ],
    roles: []
  })
  
  &gt; show collections  
  2018-05-13T20:38:09.463+0300 E QUERY    [thread1] Error: listCollections failed:   {  
          "ok" : 0,  
          "errmsg" : "not authorized on testdb to execute command {  
   listCollections: 1.0, filter: {}, $db: \"testdb\" }",  
          "code" : 13,
          "codeName" : "Unauthorized"
  } :
  _getErrorWithCode@src/mongo/shell/utils.js:25:13  
  DB.prototype._getCollectionInfosCommand@src/mongo/shell/db.js:941:1  
  DB.prototype.getCollectionInfos@src/mongo/shell/db.js:953:19  
  DB.prototype.getCollectionNames@src/mongo/shell/db.js:964:16  
  shellHelper.show@src/mongo/shell/utils.js:813:9  
  shellHelper@src/mongo/shell/utils.js:710:15  
  @(shellhelp2):1:1  
  </code></pre>