{"id":63820,"date":"2024-10-14T02:45:15","date_gmt":"2024-10-13T18:45:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/63820\/"},"modified":"2024-10-14T02:45:15","modified_gmt":"2024-10-13T18:45:15","slug":"mongodb%e8%a1%93%e8%aa%9e-%e9%99%90%e5%88%b6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/63820\/","title":{"rendered":"MongoDB\u8853\u8a9e &#8211; \u9650\u5236"},"content":{"rendered":"<h1 id=\"mongodb%e8%a1%93%e8%aa%9e-%e9%99%90%e5%88%b6-pzAPaKeKVW\">MongoDB\u8853\u8a9e &#8211; \u9650\u5236<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0cMongoDB\u4f5c\u70ba\u4e00\u7a2e\u6d41\u884c\u7684NoSQL\u6578\u64da\u5eab\uff0c\u56e0\u5176\u9748\u6d3b\u6027\u548c\u53ef\u64f4\u5c55\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u7136\u800c\uff0c\u4f7f\u7528MongoDB\u6642\uff0c\u958b\u767c\u8005\u9700\u8981\u4e86\u89e3\u4e00\u4e9b\u95dc\u9375\u7684\u8853\u8a9e\u548c\u9650\u5236\uff0c\u4ee5\u4fbf\u66f4\u6709\u6548\u5730\u7ba1\u7406\u548c\u64cd\u4f5c\u6578\u64da\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eMongoDB\u7684\u8853\u8a9e\u53ca\u5176\u9650\u5236\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u9019\u4e00\u6578\u64da\u5eab\u7cfb\u7d71\u3002<\/p>\n<h2 id=\"mongodb%e7%9a%84%e5%9f%ba%e6%9c%ac%e8%a1%93%e8%aa%9e-pzAPaKeKVW\">MongoDB\u7684\u57fa\u672c\u8853\u8a9e<\/h2>\n<ul>\n<li><strong>\u6587\u6a94\uff08Document\uff09<\/strong>\uff1aMongoDB\u4e2d\u7684\u57fa\u672c\u6578\u64da\u55ae\u4f4d\uff0c\u985e\u4f3c\u65bc\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u4e2d\u7684\u884c\u3002\u6587\u6a94\u4ee5BSON\u683c\u5f0f\u5b58\u5132\uff0c\u652f\u6301\u591a\u7a2e\u6578\u64da\u985e\u578b\u3002<\/li>\n<li><strong>\u96c6\u5408\uff08Collection\uff09<\/strong>\uff1a\u4e00\u7d44\u6587\u6a94\u7684\u96c6\u5408\uff0c\u985e\u4f3c\u65bc\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u4e2d\u7684\u8868\u3002\u96c6\u5408\u4e0d\u9700\u8981\u4e8b\u5148\u5b9a\u7fa9\u7d50\u69cb\uff0c\u9019\u4f7f\u5f97MongoDB\u5177\u6709\u9ad8\u5ea6\u7684\u9748\u6d3b\u6027\u3002<\/li>\n<li><strong>\u6578\u64da\u5eab\uff08Database\uff09<\/strong>\uff1aMongoDB\u4e2d\u7684\u6578\u64da\u5eab\u53ef\u4ee5\u5305\u542b\u591a\u500b\u96c6\u5408\u3002\u6bcf\u500b\u6578\u64da\u5eab\u90fd\u662f\u7368\u7acb\u7684\uff0c\u4e26\u4e14\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u7528\u6236\u6b0a\u9650\u3002<\/li>\n<li><strong>\u7d22\u5f15\uff08Index\uff09<\/strong>\uff1a\u7528\u65bc\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u7684\u6578\u64da\u7d50\u69cb\u3002MongoDB\u652f\u6301\u591a\u7a2e\u7d22\u5f15\u985e\u578b\uff0c\u5305\u62ec\u55ae\u5b57\u6bb5\u7d22\u5f15\u548c\u8907\u5408\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<h2 id=\"mongodb%e7%9a%84%e9%99%90%e5%88%b6-pzAPaKeKVW\">MongoDB\u7684\u9650\u5236<\/h2>\n<p>\u5118\u7ba1MongoDB\u63d0\u4f9b\u4e86\u8a31\u591a\u512a\u52e2\uff0c\u4f46\u5728\u4f7f\u7528\u904e\u7a0b\u4e2d\u4e5f\u5b58\u5728\u4e00\u4e9b\u9650\u5236\uff0c\u958b\u767c\u8005\u9700\u8981\u7279\u5225\u6ce8\u610f\uff1a<\/p>\n<h3 id=\"1-%e6%96%87%e6%aa%94%e5%a4%a7%e5%b0%8f%e9%99%90%e5%88%b6-pzAPaKeKVW\">1. \u6587\u6a94\u5927\u5c0f\u9650\u5236<\/h3>\n<p>MongoDB\u5c0d\u55ae\u500b\u6587\u6a94\u7684\u5927\u5c0f\u6709\u660e\u78ba\u7684\u9650\u5236\uff0c\u6700\u5927\u70ba16MB\u3002\u9019\u610f\u5473\u8457\u5982\u679c\u9700\u8981\u5b58\u5132\u5927\u91cf\u6578\u64da\uff0c\u958b\u767c\u8005\u9700\u8981\u8003\u616e\u5c07\u6578\u64da\u62c6\u5206\u70ba\u591a\u500b\u6587\u6a94\u3002\u4f8b\u5982\uff0c\u5c0d\u65bc\u4e00\u500b\u7528\u6236\u7684\u793e\u4ea4\u5a92\u9ad4\u5e16\u5b50\uff0c\u53ef\u80fd\u9700\u8981\u5c07\u6bcf\u500b\u5e16\u5b50\u7684\u8a55\u8ad6\u5b58\u5132\u5728\u4e0d\u540c\u7684\u6587\u6a94\u4e2d\uff0c\u4ee5\u907f\u514d\u8d85\u904e\u5927\u5c0f\u9650\u5236\u3002<\/p>\n<pre><code>{\n    \"user_id\": \"12345\",\n    \"post_id\": \"67890\",\n    \"comments\": [\n        {\"comment_id\": \"1\", \"text\": \"Great post!\"},\n        {\"comment_id\": \"2\", \"text\": \"Thanks for sharing!\"}\n    ]\n}<\/code><\/pre>\n<h3 id=\"2-%e4%ba%8b%e5%8b%99%e6%94%af%e6%8c%81-pzAPaKeKVW\">2. \u4e8b\u52d9\u652f\u6301<\/h3>\n<p>MongoDB\u5728\u65e9\u671f\u7248\u672c\u4e2d\u4e0d\u652f\u6301\u591a\u6587\u6a94\u4e8b\u52d9\uff0c\u9019\u5c0d\u65bc\u9700\u8981\u539f\u5b50\u6027\u64cd\u4f5c\u7684\u61c9\u7528\u4f86\u8aaa\u662f\u4e00\u500b\u6311\u6230\u3002\u96d6\u7136\u57284.0\u7248\u672c\u5f8c\u5f15\u5165\u4e86\u591a\u6587\u6a94\u4e8b\u52d9\uff0c\u4f46\u6027\u80fd\u53ef\u80fd\u6703\u53d7\u5230\u5f71\u97ff\u3002\u56e0\u6b64\uff0c\u5728\u8a2d\u8a08\u6578\u64da\u6a21\u578b\u6642\uff0c\u958b\u767c\u8005\u9700\u8981\u8003\u616e\u5982\u4f55\u6700\u5c0f\u5316\u4e8b\u52d9\u7684\u4f7f\u7528\u3002<\/p>\n<h3 id=\"3-%e6%9f%a5%e8%a9%a2%e6%80%a7%e8%83%bd-pzAPaKeKVW\">3. \u67e5\u8a62\u6027\u80fd<\/h3>\n<p>\u96d6\u7136MongoDB\u7684\u67e5\u8a62\u6027\u80fd\u901a\u5e38\u8f03\u597d\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u67e5\u8a62\u901f\u5ea6\u53ef\u80fd\u6703\u53d7\u5230\u5f71\u97ff\u3002\u4f8b\u5982\uff0c\u672a\u4f7f\u7528\u7d22\u5f15\u7684\u67e5\u8a62\u6703\u5c0e\u81f4\u5168\u8868\u6383\u63cf\uff0c\u5f9e\u800c\u964d\u4f4e\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u958b\u767c\u8005\u61c9\u8a72\u5b9a\u671f\u6aa2\u67e5\u548c\u512a\u5316\u7d22\u5f15\uff0c\u4ee5\u78ba\u4fdd\u67e5\u8a62\u6548\u7387\u3002<\/p>\n<h3 id=\"4-%e6%95%b8%e6%93%9a%e4%b8%80%e8%87%b4%e6%80%a7-pzAPaKeKVW\">4. \u6578\u64da\u4e00\u81f4\u6027<\/h3>\n<p>\u7531\u65bcMongoDB\u7684\u8a2d\u8a08\u7406\u5ff5\u662f\u53ef\u64f4\u5c55\u6027\u548c\u9ad8\u53ef\u7528\u6027\uff0c\u9019\u53ef\u80fd\u6703\u5c0e\u81f4\u6578\u64da\u4e00\u81f4\u6027\u554f\u984c\u3002\u5728\u5206\u4f48\u5f0f\u7cfb\u7d71\u4e2d\uff0c\u6578\u64da\u53ef\u80fd\u6703\u5728\u4e0d\u540c\u7684\u7bc0\u9ede\u4e4b\u9593\u51fa\u73fe\u5ef6\u9072\uff0c\u9019\u5c0d\u65bc\u9700\u8981\u5373\u6642\u6578\u64da\u7684\u61c9\u7528\u4f86\u8aaa\u662f\u4e00\u500b\u6311\u6230\u3002\u958b\u767c\u8005\u9700\u8981\u6839\u64da\u5177\u9ad4\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u4e00\u81f4\u6027\u6a21\u578b\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-pzAPaKeKVW\">\u7d50\u8ad6<\/h2>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cMongoDB\u4f5c\u70ba\u4e00\u7a2e\u5f37\u5927\u7684NoSQL\u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\u548c\u9ad8\u6548\u7684\u67e5\u8a62\u6027\u80fd\u3002\u7136\u800c\uff0c\u958b\u767c\u8005\u5728\u4f7f\u7528MongoDB\u6642\u5fc5\u9808\u4e86\u89e3\u5176\u8853\u8a9e\u53ca\u9650\u5236\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u8a2d\u8a08\u548c\u7ba1\u7406\u6578\u64da\u3002\u901a\u904e\u5408\u7406\u7684\u6578\u64da\u5efa\u6a21\u548c\u7d22\u5f15\u7b56\u7565\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u514b\u670d\u9019\u4e9b\u9650\u5236\uff0c\u5145\u5206\u767c\u63eeMongoDB\u7684\u6f5b\u529b\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684MongoDB\u6578\u64da\u5eab\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u5ba2\u6236\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u985e\u578b\u7684 <a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a>\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3MongoDB\u4e2d\u7684\u9650\u5236\u8853\u8a9e\uff0c\u638c\u63e1\u6578\u64da\u5eab\u6027\u80fd\u3001\u5bb9\u91cf\u548c\u64cd\u4f5c\u7684\u95dc\u9375\u8981\u7d20\uff0c\u63d0\u5347\u60a8\u7684\u958b\u767c\u6548\u7387\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-63820","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=63820"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63820\/revisions"}],"predecessor-version":[{"id":63821,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63820\/revisions\/63821"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=63820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=63820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=63820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}