{"id":286528,"date":"2017-05-18T12:10:03","date_gmt":"2017-05-18T08:10:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286528"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286528","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Web API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c .NET Core + MongoDB .NET Driver"},"content":{"rendered":"<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, MongoDB \u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u0445, open-source NoSQL \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u043e\u0441\u0441-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 open-source \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 NoSQL \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e \u0441\u0432\u043e\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0438\u0445 \u043d\u0435\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 ASP.NET Core Web API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u00ab\u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 MongoDB.<a name=\"habracut\"><\/a><\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 MongoDB<\/h2>\n<p>  \u0412\u044b\u0431\u043e\u0440 \u0421\u0423\u0411\u0414 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0422.\u0435. \u0411\u0414 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0430 \u0441\u0430\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 MongoDB \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c. \u042f\u0440\u043a\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0431\u043b\u043e\u0433 \u0438\u043b\u0438 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a \u043d\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0432\u0438\u0434\u0435\u043e \u0438 \u043c\u0443\u0437\u044b\u043a\u0443. \u0414\u0440\u0443\u0433\u0438\u0435 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0446\u0435\u043d\u043e\u043a \u00ab\u041d\u0440\u0430\u0432\u0438\u0442\u0441\u044f\u00bb \u0438\u043b\u0438 \u00ab\u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043d\u043e\u0439\u00bb \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041d\u043e \u043a\u0430\u043a \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435? \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0421\u0423\u0411\u0414, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/90f\/d7d\/e53\/90fd7de53a3f43889d2d972cc54e4fa5.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u0435\u0451 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430\u0443\u0434\u0438\u043e, \u0432\u0438\u0434\u0435\u043e, \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043e\u0446\u0435\u043d\u043a\u0438, \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438 \u0442.\u0434.) \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u043e\u0441\u044c\u043c\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c \u0442\u0430\u0431\u043b\u0438\u0446. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043d\u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432) \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0438 \u0432\u044b \u043f\u043e\u0439\u043c\u0451\u0442\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0442\u044b\u0441\u044f\u0447\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0411\u0414, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 SQL Server, \u0442.\u043a. SQL \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <a href=\"https:\/\/msdn.microsoft.com\/library\/dn921897.aspx\">\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON<\/a>. \u041d\u043e \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u2014 \u044d\u0442\u043e \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 NoSQL. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u0438\u043d \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0435\u0433\u043e \u0432 MongoDB, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0435\u0437 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446. \u042d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. <\/p>\n<pre><code>{     &quot;id&quot;:&quot;ew12-res2-234e-544f&quot;,     &quot;title&quot;:&quot;post title&quot;,     &quot;date&quot;:&quot;2016-01-01&quot;,     &quot;body&quot;:&quot;this is an awesome post stored on NoSQL&quot;,     &quot;createdBy&quot;:&quot;User&quot;,     &quot;images&quot;:[&quot;http:\/\/example.com\/myfirstimage.png&quot;,&quot;http:\/\/example.com\/mysecondimage.png&quot;],     &quot;videos&quot;:[         {&quot;url&quot;:&quot;http:\/\/example.com\/myfirstvideo.mp4&quot;, &quot;title&quot;:&quot;The first video&quot;},         {&quot;url&quot;:&quot;http:\/\/example.com\/mysecondvideo.mp4&quot;, &quot;title&quot;:&quot;The second video&quot;}     ],     &quot;audios&quot;:[         {&quot;url&quot;:&quot;http:\/\/example.com\/myfirstaudio.mp3&quot;, &quot;title&quot;:&quot;The first audio&quot;},         {&quot;url&quot;:&quot;http:\/\/example.com\/mysecondaudio.mp3&quot;, &quot;title&quot;:&quot;The second audio&quot;}     ] }<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 MongoDB \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043e\u0441\u043b\u0430\u0431\u043b\u044f\u0442\u044c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439.<br \/>  \u041f\u0440\u043e\u0448\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c MongoDB \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414, \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430. \u0414\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u2014 \u0447\u0442\u043e-\u0442\u043e \u043b\u0443\u0447\u0448\u0435, \u0430 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u0442. <\/p>\n<p>  \u0411\u0435\u0441\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432 MongoDB \u043d\u0435 \u043e\u0431\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u0412\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442? \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u0432 BSON \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u0432 MongoDB. \u041d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u043b\u0438 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  \u042d\u0442\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u0432\u0430\u043c \u043a\u0430\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443.<\/p>\n<p>  \u0414\u043e \u0432\u0435\u0440\u0441\u0438\u0438 1.8 MongoDB \u0441\u0447\u0438\u0442\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043d\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0438\u0441\u043a \u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u0435\u043a<\/h2>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 MongoDB \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u0445\u0435\u043c\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 BSON (Binary JavaScript Object Notation), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0430 JSON, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0434\u0430\u0442\u044b. \u0421\u0445\u0435\u043c\u0430 \u0432 MongoDB \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439<\/b>, \u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c<\/b>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/a71\/140\/df5\/a71140df51234ac9a89bcc9420f07981.png\" alt=\"image\"\/><\/p>\n<p>  ASP.NET Core Web API \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043b\u044e\u0431\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 Windows, MacOS \u0438 Linux.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 MongoDB \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 EF Core. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u043e \u0448\u0430\u043d\u0441\u043e\u0432, \u0447\u0442\u043e \u0433\u0440\u044f\u0434\u0443\u0449\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 EF Core \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c MongoDB (\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2016\/06\/27\/entity-framework-core-1-0-0-available\/\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432<\/a> \u0420\u043e\u0443\u044d\u043d\u0430 \u041c\u0438\u043b\u043b\u0435\u0440\u0430), \u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.visualstudio.com\/ru\/free-developer-offers\/\">Visual Studio Community 2017<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0432 \u0441\u0435\u0431\u044f .NET Core<\/li>\n<li><a href=\"https:\/\/www.mongodb.com\/download-center#community\">MongoDB<\/a>, \u0432\u0435\u0440\u0441\u0438\u044f 3.4<\/li>\n<li><a href=\"https:\/\/robomongo.org\/\">Robomongo<\/a> \u2014 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 MongoDB <\/li>\n<li><a href=\"https:\/\/www.getpostman.com\/\">Postman<\/a> \u2014 c\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Web API<\/li>\n<\/ul>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f MongoDB<\/h2>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 <a href=\"https:\/\/www.mongodb.com\/download-center#community\">MongoDB<\/a>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0411\u0414, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0433\u0434\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <b>mongod.cfg<\/b>. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 MongoDB, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0430\u0439\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 MongoDB, \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code>systemLog:   destination: file   path: &quot;C:\\\\data\\\\db\\\\log\\\\mongo.log&quot;   logAppend: true storage:   dbPath: &quot;C:\\\\data\\\\db&quot;<\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e MongoDB \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0411\u0414 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>&quot;C:\\\\data\\\\db&quot;<\/code> \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. <\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0430\u043f\u043a\u0438, \u043a\u0443\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 MongoDB).<br \/>  <code>&quot;C:\\Program Files\\MongoDB\\Server\\3.4\\bin\\mongod.exe&quot; --config C:\\Dev\\mongod.cfg<\/code><br \/>  \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 MongoDB, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043d\u0430 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u0423\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043a \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c. \u0414\u043b\u044f \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e PATH.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d (\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 \u043b\u043e\u0433\u043e\u0432), \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043b\u0438\u0435\u043d\u0442 <b>mongo.exe<\/b> \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/175\/ef6\/e48\/175ef6e482674e82a24d67ca080827b8.png\" alt=\"image\"\/><br \/>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u043a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0434\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/155\/f84\/9aa\/155f849aafd64c058dd0251b16193c2d.png\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0435:<\/p>\n<pre><code>use admin db.createUser(   { \tuser: &quot;admin&quot;, \tpwd: &quot;abc123!&quot;, \troles: [ { role: &quot;root&quot;, db: &quot;admin&quot; } ]   } ); exit; <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 mongod.cfg, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code>systemLog:   destination: file   path: &quot;C:\\\\data\\\\db\\\\log\\\\mongo.log&quot;   logAppend: true storage:   dbPath: &quot;C:\\\\data\\\\db&quot; security:   authorization: enabled<\/code><\/pre>\n<p>  \u0421 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a MongoDB \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <i>admin<\/i>. <\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u043e\u043b\u044c \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430) \u0434\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 ASP.NET Web API \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>  \u0413\u043e\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441 <a href=\"https:\/\/github.com\/artholy\/WebApiMongoDB\/\">GitHub<\/a>.<br \/>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c Visual Studio, File &gt; New Project &gt; .Net Core &gt; ASP.NET Core Web Application.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/f25\/628\/97b\/f2562897b7e04855a8fddd5d2a41c2eb.png\" alt=\"image\"\/><\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d Web API, OK.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/e69\/aff\/5b2\/e69aff5b21d84d098532c936a312d97a.png\" alt=\"image\"\/><\/p>\n<h3>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (JSON, XML \u0438\u043b\u0438 ini), \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Web API \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u041e\u0431\u043d\u043e\u0432\u0438\u043c \u0444\u0430\u0439\u043b AppSettings.json, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code>{   &quot;Logging&quot;: {     &quot;IncludeScopes&quot;: false,     &quot;LogLevel&quot;: {       &quot;Default&quot;: &quot;Debug&quot;,       &quot;Microsoft&quot;: &quot;Information&quot;,       &quot;System&quot;: &quot;Information&quot;     }   },   &quot;MongoConnection&quot;: {     &quot;ConnectionString&quot;: &quot;mongodb:\/\/admin:abc123!@localhost&quot;,     &quot;Database&quot;: &quot;NotesDb&quot;   } }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/h3>\n<p>  \u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 (Constructor Injection) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (Dependency Injection). ASP.NET Core \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0432 \u0441\u0432\u043e\u0451\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0430\u043f\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/p>\n<pre><code>namespace NotebookAppApi.Model {     public class Settings     {         public string ConnectionString;         public string Database;     } }<\/code><\/pre>\n<p>  \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 ConfigureSettings \u0432 \u0444\u0430\u0439\u043b\u0435 Startup.cs \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IOptions \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c.<\/p>\n<pre><code>public void ConfigureServices(IServiceCollection services) {     \/\/ Add framework services.     services.AddMvc();      services.Configure&lt;Settings&gt;(options =&gt;     {         options.ConnectionString = Configuration.GetSection(&quot;MongoConnection:ConnectionString&quot;).Value;         options.Database = Configuration.GetSection(&quot;MongoConnection:Database&quot;).Value;     }); }<\/code><\/pre>\n<p>  <\/p>\n<h3>MongoDB .NET Driver<\/h3>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a MongoDB, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 Nuget \u043f\u0430\u043a\u0435\u0442 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c MongoDB.Driver. \u042d\u0442\u043e \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043b\u044f .NET \u0441 \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 ASP.NET Core. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/5a5\/150\/546\/5a51505465214868a24b480ee972db16.png\" alt=\"image\"\/><\/p>\n<h3>\u041c\u043e\u0434\u0435\u043b\u044c<\/h3>\n<p>  \u041c\u043e\u0434\u0435\u043b\u044c \u043a\u043b\u0430\u0441\u0441\u0430 (POCO), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u043c\u0435\u0442\u043a\u0443 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code>using System; using MongoDB.Bson.Serialization.Attributes;  namespace NotebookAppApi.Model {     public class Note     {         [BsonId]         public string Id { get; set; }         public string Body { get; set; } = string.Empty;         public DateTime UpdatedOn { get; set; } = DateTime.Now;         public DateTime CreatedOn { get; set; } = DateTime.Now;         public int UserId { get; set; } = 0;     } }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d Unit of Work \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 NoteContext: <\/p>\n<pre><code>public class NoteContext {     private readonly IMongoDatabase _database = null;      public NoteContext(IOptions settings)     {         var client = new MongoClient(settings.Value.ConnectionString);         if (client != null)             _database = client.GetDatabase(settings.Value.Database);     }      public IMongoCollection Notes     {         get         {             return _database.GetCollection(&quot;Note&quot;);         }     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/h3>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438. \u041e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (DI) \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0437\u0434\u0435\u043b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430).<\/p>\n<pre><code> public interface INoteRepository     {         Task&lt;IEnumerable&lt;Note&gt;&gt; GetAllNotes();         Task&lt;Note&gt; GetNote(string id);         Task AddNote(Note item);         Task&lt;DeleteResult&gt; RemoveNote(string id);         \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f (body) \u0437\u0430\u043f\u0438\u0441\u0438         Task&lt;UpdateResult&gt; UpdateNote(string id, string body);     } <\/code><\/pre>\n<p>  \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0411\u0414 \u0431\u0443\u0434\u0435\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0435 \u043d\u0438\u0436\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 2.0, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a. \u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440: \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043c\u0435\u0442\u043a\u0438, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code>public async Task&lt;IEnumerable&lt;Note&gt;&gt; GetAllNotes() {     return await _context.Notes.Find(_ =&gt; true).ToListAsync(); }<\/code><\/pre>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u043b\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<pre><code>namespace NotebookAppApi.Data {     public class NoteRepository : INoteRepository     {         private readonly NoteContext _context = null;          public NoteRepository(IOptions&lt;Settings&gt; settings)         {             _context = new NoteContext(settings);         }          public async Task&lt;IEnumerable&lt;Note&gt;&gt; GetAllNotes()         {             return await _context.Notes.Find(_ =&gt; true).ToListAsync();         }          public async Task&lt;Note&gt; GetNote(string id)         {             var filter = Builders&lt;Note&gt;.Filter.Eq(&quot;Id&quot;, id);             return await _context.Notes                             .Find(filter)                             .FirstOrDefaultAsync();         }          public async Task AddNote(Note item)         {             await _context.Notes.InsertOneAsync(item);         }          public async Task&lt;DeleteResult&gt; RemoveNote(string id)         {             return await _context.Notes.DeleteOneAsync(                  Builders&lt;Note&gt;.Filter.Eq(&quot;Id&quot;, id));         }          public async Task&lt;UpdateResult&gt; UpdateNote(string id, string body)         {             var filter = Builders&lt;Note&gt;.Filter.Eq(s =&gt; s.Id, id);             var update = Builders&lt;Note&gt;.Update                             .Set(s =&gt; s.Body, body)                             .CurrentDate(s =&gt; s.UpdatedOn);              return await _context.Notes.UpdateOneAsync(filter, update);         }     } }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a NoteRepository \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u0438 DI, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 ConfigureServices:<\/p>\n<pre><code>services.AddTransient&lt;INoteRepository, NoteRepository&gt;();<\/code><\/pre>\n<p>  \u0433\u0434\u0435:  <\/p>\n<ul>\n<li>AddTransient \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437.<\/li>\n<li>AddScoped \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043d\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441.<\/li>\n<li>AddSingleton \u2014 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/h3>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e Web API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 CRUD \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c. <\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: \u043c\u0435\u0442\u043e\u0434 Get \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c NoCache, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0435\u0431-\u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<pre><code>namespace NotebookAppApi.Controllers {     [Produces(&quot;application\/json&quot;)]     [Route(&quot;api\/[controller]&quot;)]     public class NotesController : Controller     {         private readonly INoteRepository _noteRepository;          public NotesController(INoteRepository noteRepository)         {             _noteRepository = noteRepository;         }          [NoCache]         [HttpGet]         public Task&lt;IEnumerable&lt;Note&gt;&gt; Get()         {             return GetNoteInternal();         }          private async Task&lt;IEnumerable&lt;Note&gt;&gt; GetNoteInternal()         {             return await _noteRepository.GetAllNotes();         }          \/\/ GET api\/notes\/5         [HttpGet(&quot;{id}&quot;)]         public Task&lt;Note&gt; Get(string id)         {             return GetNoteByIdInternal(id);         }          private async Task&lt;Note&gt; GetNoteByIdInternal(string id)         {             return await _noteRepository.GetNote(id) ?? new Note();         }          \/\/ POST api\/notes         [HttpPost]         public void Post([FromBody]string value)         {             _noteRepository.AddNote(new Note() { Body = value, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now });         }          \/\/ PUT api\/notes\/5         [HttpPut(&quot;{id}&quot;)]         public void Put(string id, [FromBody]string value)         {             _noteRepository.UpdateNoteDocument(id, value);         }          \/\/ DELETE api\/notes\/23243423         [HttpDelete(&quot;{id}&quot;)]         public void Delete(string id)         {             _noteRepository.RemoveNote(id);         }     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0446\u0435\u043b\u044f\u0445 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 (\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445). <\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 Init, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442 \u0411\u0414 \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u043c <a href=\"http:\/\/localhost:5000\/api\/system\/init\">http:\/\/localhost:5000\/api\/system\/init<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/localhost:53617\/api\/system\/init\">http:\/\/localhost:53617\/api\/system\/init<\/a> (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c IIS). \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u043e\u0433 \u0431\u044b \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u00ab\u0430\u0434\u043c\u0438\u043d\u043a\u0443\u00bb.<\/p>\n<pre><code>[Route(&quot;api\/[controller]&quot;)] public class SystemController : Controller {     private readonly INoteRepository _noteRepository;      public SystemController(INoteRepository noteRepository)     {         _noteRepository = noteRepository;     }      \/\/ Call an initialization - api\/system\/init     [HttpGet(&quot;{setting}&quot;)]     public string Get(string setting)     {         if (setting == &quot;init&quot;)         {             _noteRepository.RemoveAllNotes();             _noteRepository.AddNote(new Note() { Id = &quot;1&quot;, Body = &quot;Test note 1&quot;,                            CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UserId = 1 });             _noteRepository.AddNote(new Note() { Id = &quot;2&quot;, Body = &quot;Test note 2&quot;,                            CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UserId = 1 });             _noteRepository.AddNote(new Note() { Id = &quot;3&quot;, Body = &quot;Test note 3&quot;,                            CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UserId = 2 });             _noteRepository.AddNote(new Note() { Id = &quot;4&quot;, Body = &quot;Test note 4&quot;,                            CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UserId = 2 });              return &quot;Done&quot;;         }          return &quot;Unknown&quot;;     } } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/h3>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0444\u0430\u0439\u043b LaunchSettings.json<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/dda\/e4b\/04d\/ddae4b04d26345bfaa0c2214932db876.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f URL-\u0430\u0434\u0440\u0435\u0441 \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a (api\/notes). <\/p>\n<pre><code>{   &quot;iisSettings&quot;: {     &quot;windowsAuthentication&quot;: false,     &quot;anonymousAuthentication&quot;: true,     &quot;iisExpress&quot;: {       &quot;applicationUrl&quot;: &quot;http:\/\/localhost:53617\/&quot;,       &quot;sslPort&quot;: 0     }   },   &quot;profiles&quot;: {     &quot;IIS Express&quot;: {       &quot;commandName&quot;: &quot;IISExpress&quot;,       &quot;launchBrowser&quot;: true,       &quot;launchUrl&quot;: &quot;api\/notes&quot;,       &quot;environmentVariables&quot;: {         &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;       }     },     &quot;NotebookAppApi&quot;: {       &quot;commandName&quot;: &quot;Project&quot;,       &quot;launchBrowser&quot;: true,       &quot;launchUrl&quot;: &quot;http:\/\/localhost:5000\/api\/notes&quot;,       &quot;environmentVariables&quot;: {         &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;       }     }   } }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e MongoDB \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 (\u043a\u0430\u043a \u0441\u043b\u0443\u0436\u0431\u0430 Windows, \u043b\u0438\u0431\u043e \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u044b\u0448\u0435). <br \/>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0441 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u043d\u043e \u0442.\u043a. \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/97a\/f6f\/323\/97af6f3230cc4aacb976d6733fdfc059.png\" alt=\"image\"\/><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0411\u0414 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0435\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e <a href=\"http:\/\/localhost:53617\/api\/system\/init\">\u0430\u0434\u0440\u0435\u0441\u0443<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/778\/06e\/51b\/77806e51b55f4c83a2ccd8c83ad03a2a.png\" alt=\"image\"\/><\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c, \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c: <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/6ad\/475\/83c\/6ad47583cc85470285ae89015c37347e.png\" alt=\"image\"\/><\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Robomongo<\/h3>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Robomongo \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0443\u0447\u0435\u0442\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 4 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/27e\/69d\/876\/27e69d8769a54103b65260c902c85cfd.png\" alt=\"image\"\/><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>  \u0412 C# 5.0 \u0431\u044b\u043b\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 async \u0438 await, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 TPL (Task Parallel Library). \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a try\/catch \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.public async Task&lt;IEnumerable&gt; GetAllNotes()<\/p>\n<pre><code>{     try     {         return await _context.Notes.Find(_ =&gt; true).ToListAsync();     }     catch (Exception ex)     {         \/\/ log or manage the exception         throw;     } }<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 Task, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0448\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h2>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 MongoDB<\/h2>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 ReplaceOneAsync \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 IsUpsert \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432 \u0411\u0414, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c.<\/p>\n<pre><code>public async Task&lt;ReplaceOneResult&gt; UpdateNote(string id, Note item) {      return await _context.Notes                           .ReplaceOneAsync(n =&gt; n.Id.Equals(id)                                             , item                                             , new UpdateOptions { IsUpsert = true }); }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (CORS)<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u043e\u043c\u0435\u043d\u0430\u0445, \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 ASP.NET Web API \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (CORS). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/angular.io\/\">Angular 2<\/a> \u043f\u0435\u0440\u0435\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 pre-check \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0436\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0442\u043e\u0433\u043e, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b \u043b\u0438 \u043c\u0435\u0436\u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b CORS \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 ConfigureServices \u0444\u0430\u0439\u043b\u0430 Startup.cs:<\/p>\n<pre><code>public void ConfigureServices(IServiceCollection services)   {       \/\/ Add service and create Policy with options        services.AddCors(options =&gt; { options.AddPolicy(&quot;CorsPolicy&quot;,                                        builder =&gt; builder.AllowAnyOrigin()                                                          .AllowAnyMethod()                                                          .AllowAnyHeader()                                                          .AllowCredentials());                                    });        \/\/ ....         services.AddMvc();   }<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 app.useCors \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Configure: <\/p>\n<pre><code>public void Configure(IApplicationBuilder app) {     app.UseCors(&quot;CorsPolicy&quot;);     app.UseMvc(); }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438<\/h2>\n<p>  \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 MongoDB \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432 MongoDB 2.x \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 16 \u041c\u0431 (\u0432 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u2014 \u043b\u0438\u0448\u044c 4 \u041c\u0431). \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u0432 MongoDB \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 GridFS. GridFS \u2014 \u044d\u0442\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432 MongoDB, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0432\u0441\u0435\u043c\u0438 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438. \u0424\u0430\u0439\u043b\u044b \u0432 \u0411\u0414 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445, \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u00abfs.files\u00bb \u0438 \u00abfs.chunks\u00bb. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u0438\u043d \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u00abfs.files\u00bb, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0444\u0430\u0439\u043b\u0435 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432-\u043a\u0443\u0441\u043a\u043e\u0432 (\u0447\u0430\u043d\u043a\u043e\u0432) \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u00abfs.chunks\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c. <\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b GridFS \u0434\u043b\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 NuGet.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/01c\/a26\/50b\/01ca2650b08d422eae482ee62f264a60.png\" alt=\"image\"\/><\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <b>GridFSBucket<\/b> \u0432 \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. <b>GridFSBucket<\/b> \u2014 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GridFS, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u00abfs.files\u00bb \u0438 \u00abfs.chunks\u00bb \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u00ab\u0432\u0435\u0434\u0440\u043e\u00bb (Bucket), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0444\u0430\u0439\u043b\u044b. <\/p>\n<pre><code>_database = client.GetDatabase(settings.Value.Database); _bucket = new GridFSBucket(_database);<\/code><\/pre>\n<p>  \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (\u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u00abfs\u00bb \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435) \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0430\u043d\u043a\u0430.<\/p>\n<pre><code> _database = client.GetDatabase(settings.Value.Database);  var gridFSBucketOptions = new GridFSBucketOptions()  {      BucketName = &quot;images&quot;,      ChunkSizeBytes = 1048576, \/\/ 1\u041c\u0411  };  _bucket = new GridFSBucket(_database, gridFSBucketOptions);<\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <b>GridFSBucket<\/b>: <\/p>\n<pre><code>public GridFSBucket Bucket {     get     {         return _bucket;     } }<\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code>public GridFSBucket Bucket =&gt; _bucket;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u043d\u0430\u0448 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0432 \u0411\u0414 \u0432 NoteRepository.cs<\/p>\n<pre><code>     public async Task&lt;ObjectId&gt; UploadFile(IFormFile file)         {             try             {                 var stream = file.OpenReadStream();                 var filename = file.FileName;                 return await _context.Bucket.UploadFromStreamAsync(filename, stream);             }             catch (Exception ex)             {                 return new ObjectId(ex.ToString());             }          }<\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 GridFSBucket \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 GridFS (\u00abfs.chunks\u00bb \u0438 \u00abfs.files\u00bb) \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c. <\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 INoteRepository.cs:<\/p>\n<pre><code>Task&lt;ObjectId&gt; UploadFile(IFormFile file);<\/code><\/pre>\n<p>  \u041e\u0431\u043d\u043e\u0432\u0438\u043c NotesController.cs, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0441\u0430\u043c POST \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code>\/\/ POST api\/notes\/uploadFile [HttpPost(&quot;uploadFile&quot;)] public async Task&lt;ObjectId&gt; UploadFile(IFormFile file) {     return await _noteRepository.UploadFile(file); }<\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: <\/b> \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c Content-Type: multipart\/form-data (\u0442\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 NotesController \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 Consumes: <\/p>\n<pre><code>[Consumes(&quot;application\/json&quot;, &quot;multipart\/form-data&quot;)] public class NotesController : Controller<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0444\u0430\u0439\u043b\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e Id \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code>       public async Task&lt;String&gt; GetFileInfo(string id)         {             GridFSFileInfo info = null;             var objectId = new ObjectId(id);             try             {                 using (var stream = await _context.Bucket.OpenDownloadStreamAsync(objectId))                 {                     info = stream.FileInfo;                 }                 return info.Filename;             }             catch (Exception)             {                 return &quot;Not Found&quot;;             }         }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448 API<\/h2>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b Web API \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.getpostman.com\/\">Postman<\/a>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e Id (api\/notes\/2) \u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET, \u0437\u0430\u0442\u0435\u043c \u0432\u0432\u0435\u0434\u0435\u043c URL (http:\/\/localhost:53617\/api\/notes\/2) \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (Content-Type: application\/json). \u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 Id = 2.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/b18\/d60\/bce\/b18d60bce48545838afa99feac7f2cb9.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 PUT, \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Body &gt; Raw \u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/a68\/5ae\/620\/a685ae6207c3454090e7061408a4783f.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0439\u0434\u0435\u043c \u0432 RoboMongo \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/8c3\/f53\/b7a\/8c3f53b7a808459cb3d7ca8900d9ba62.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 GridFS. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c Content-Type \u043d\u0430 multipart\/form-data, URL \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a <a href=\"http:\/\/localhost\">localhost<\/a>:53617\/api\/notes\/uploadFile \u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Body &gt; form-data \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b. \u0412 \u043e\u0442\u0432\u0435\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/6f2\/c4c\/f75\/6f2c4cf756624dd780d0212baefa5ecf.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043b\u0438\u0441\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445 \u00abimages.files\u00bb \u0438 \u00abimages.chunks\u00bb.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/196\/610\/617\/196610617dec4c06a65fa27391ebc191.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0435\u0433\u043e ID. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 GET \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 ID \u0444\u0430\u0439\u043b\u0430 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/082\/6d6\/127\/0826d612709a43489f2265097d30c3e8.png\" alt=\"image\"\/><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0430\u043c \u0444\u0430\u043a\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 MongoDB \u0443\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c, \u043f\u0440\u043e\u0432\u043e\u0434\u044f <a href=\"https:\/\/university.mongodb.com\/\">\u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043a\u0443\u0440\u0441\u044b<\/a>, \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044f\u0441\u044c \u043c\u043d\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/www.mongodb.com\/presentations\/\">\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430<\/a> \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0435\u0448\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 <a href=\"https:\/\/jira.mongodb.org\/secure\/Dashboard.jspa\">\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/a> (\u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0438\u0448\u0443\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043b\u043e\u043d\u0442\u0435\u0440\u044b, \u043d\u043e \u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u043b\u044e\u0434\u0435\u0439 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0439 \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438), \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e MongoDB \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043c\u043f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u0418 \u0442\u043e, \u0447\u0442\u043e MongoDB \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Windows, \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0437\u0440\u0435\u043b\u043e\u0441\u0442\u044c\u044e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438 \u043a\u0443\u0440\u0441\u043e\u043c Microsoft \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 .NET Core \u0432 Linux \u0438 MacOS, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u044b\u043c \u043f\u043b\u044e\u0441\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 Linux. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043f\u0440\u043e <a href=\"https:\/\/www.microsoft.com\/ru-ru\/sql-server\/sql-server-vnext-including-linux\">\u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> SQL Server 2017, \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430 Linux. \u0418 \u0432\u044b\u0431\u043e\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: NoSQL \u0438\u043b\u0438 RDBMS \u2014 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0438 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. MongoDB \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u0441\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u0440\u0430\u0437\u0443 \u0432\u0437\u044f\u0442\u044c \u0420\u0421\u0423\u0411\u0414.<\/p>\n<p>  <b>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:<\/b>  <\/p>\n<ol>\n<li><a href=\"http:\/\/www.qappdesign.com\/using-mongodb-with-net-core-webapi\/\">http:\/\/www.qappdesign.com\/using-mongodb-with-net-core-webapi\/<\/a><\/li>\n<li><a href=\"http:\/\/jsman.ru\/mongo-book\/Vvedenie.html\">http:\/\/jsman.ru\/mongo-book\/Vvedenie.html<\/a><\/li>\n<li><a href=\"http:\/\/mongodb.github.io\/mongo-csharp-driver\/2.4\/reference\/\">http:\/\/mongodb.github.io\/mongo-csharp-driver\/2.4\/reference\/<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/azure\/documentdb\/documentdb-nosql-vs-sql\">https:\/\/docs.microsoft.com\/ru-ru\/azure\/documentdb\/documentdb-nosql-vs-sql<\/a><\/li>\n<\/ol>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328954\/\"> https:\/\/habrahabr.ru\/post\/328954\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, MongoDB \u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u0445, open-source NoSQL \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u043e\u0441\u0441-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 open-source \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 NoSQL \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e \u0441\u0432\u043e\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0438\u0445 \u043d\u0435\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 ASP.NET Core Web API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u00ab\u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 MongoDB.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286528","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286528"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286528\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}