{"id":153265,"date":"2024-11-02T06:00:20","date_gmt":"2024-11-01T22:00:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/153265\/"},"modified":"2024-11-02T06:00:21","modified_gmt":"2024-11-01T22:00:21","slug":"%e5%be%9e%e5%96%ae%e6%a9%9f%e5%88%b0%e5%88%86%e5%b8%83%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%98%e5%84%b2%e7%b3%bb%e7%b5%b1%e7%9a%84%e6%bc%94%e9%80%b2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/153265\/","title":{"rendered":"\u5f9e\u55ae\u6a5f\u5230\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u5b58\u5132\u7cfb\u7d71\u7684\u6f14\u9032"},"content":{"rendered":"<h1 id=\"%e5%be%9e%e5%96%ae%e6%a9%9f%e5%88%b0%e5%88%86%e5%b8%83%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%98%e5%84%b2%e7%b3%bb%e7%b5%b1%e7%9a%84%e6%bc%94%e9%80%b2-qffICZsuIQ\">\u5f9e\u55ae\u6a5f\u5230\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u5b58\u5132\u7cfb\u7d71\u7684\u6f14\u9032<\/h1>\n<p>\u96a8\u8457\u79d1\u6280\u7684\u9032\u6b65\u548c\u6578\u64da\u91cf\u7684\u6fc0\u589e\uff0c\u6578\u64da\u5eab\u7684\u5b58\u5132\u7cfb\u7d71\u4e5f\u7d93\u6b77\u4e86\u986f\u8457\u7684\u6f14\u8b8a\u3002\u5f9e\u6700\u521d\u7684\u55ae\u6a5f\u6578\u64da\u5eab\u5230\u5982\u4eca\u7684\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7cfb\u7d71\uff0c\u9019\u4e00\u904e\u7a0b\u4e0d\u50c5\u53cd\u6620\u4e86\u6280\u8853\u7684\u767c\u5c55\uff0c\u4e5f\u986f\u793a\u4e86\u5c0d\u6578\u64da\u7ba1\u7406\u9700\u6c42\u7684\u8b8a\u5316\u3002<\/p>\n<h2 id=\"%e5%96%ae%e6%a9%9f%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e7%89%b9%e9%bb%9e-qffICZsuIQ\">\u55ae\u6a5f\u6578\u64da\u5eab\u7684\u7279\u9ede<\/h2>\n<p>\u55ae\u6a5f\u6578\u64da\u5eab\u662f\u6307\u5728\u55ae\u4e00\u4f3a\u670d\u5668\u4e0a\u904b\u884c\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u3002\u9019\u7a2e\u7cfb\u7d71\u7684\u512a\u9ede\u5728\u65bc\u5176\u7c21\u55ae\u6027\u548c\u6613\u65bc\u7ba1\u7406\u3002\u5e38\u898b\u7684\u55ae\u6a5f\u6578\u64da\u5eab\u5305\u62ec MySQL\u3001SQLite \u548c PostgreSQL \u7b49\u3002\u9019\u4e9b\u6578\u64da\u5eab\u901a\u5e38\u9069\u7528\u65bc\u5c0f\u578b\u61c9\u7528\u6216\u958b\u767c\u74b0\u5883\uff0c\u56e0\u70ba\u5b83\u5011\u80fd\u5920\u5feb\u901f\u97ff\u61c9\u67e5\u8a62\u4e26\u4e14\u914d\u7f6e\u76f8\u5c0d\u7c21\u55ae\u3002<\/p>\n<ul>\n<li><strong>\u512a\u9ede\uff1a<\/strong>\u6613\u65bc\u5b89\u88dd\u548c\u914d\u7f6e\uff0c\u6027\u80fd\u7a69\u5b9a\uff0c\u9069\u5408\u5c0f\u578b\u61c9\u7528\u3002<\/li>\n<li><strong>\u7f3a\u9ede\uff1a<\/strong>\u64f4\u5c55\u6027\u5dee\uff0c\u7121\u6cd5\u8655\u7406\u5927\u91cf\u4e26\u767c\u8acb\u6c42\uff0c\u55ae\u9ede\u6545\u969c\u98a8\u96aa\u9ad8\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%be%9e%e5%96%ae%e6%a9%9f%e5%88%b0%e5%88%86%e5%b8%83%e5%bc%8f%e7%9a%84%e9%9c%80%e6%b1%82-qffICZsuIQ\">\u5f9e\u55ae\u6a5f\u5230\u5206\u5e03\u5f0f\u7684\u9700\u6c42<\/h2>\n<p>\u96a8\u8457\u4e92\u806f\u7db2\u7684\u666e\u53ca\u548c\u6578\u64da\u91cf\u7684\u7206\u70b8\u6027\u589e\u9577\uff0c\u55ae\u6a5f\u6578\u64da\u5eab\u9010\u6f38\u7121\u6cd5\u6eff\u8db3\u4f01\u696d\u7684\u9700\u6c42\u3002\u7279\u5225\u662f\u5728\u9ad8\u6d41\u91cf\u7684\u61c9\u7528\u5834\u666f\u4e2d\uff0c\u55ae\u6a5f\u6578\u64da\u5eab\u9762\u81e8\u8457\u6027\u80fd\u74f6\u9838\u548c\u53ef\u7528\u6027\u554f\u984c\u3002\u9019\u4fc3\u4f7f\u4e86\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7684\u51fa\u73fe\u3002<\/p>\n<h3 id=\"%e5%88%86%e5%b8%83%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%a6%82%e5%bf%b5-qffICZsuIQ\">\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7684\u6982\u5ff5<\/h3>\n<p>\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u662f\u6307\u5c07\u6578\u64da\u5206\u6563\u5b58\u5132\u5728\u591a\u500b\u4f3a\u670d\u5668\u4e0a\uff0c\u9019\u4e9b\u4f3a\u670d\u5668\u53ef\u4ee5\u4f4d\u65bc\u4e0d\u540c\u7684\u5730\u7406\u4f4d\u7f6e\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6578\u64da\u7684\u53ef\u7528\u6027\uff0c\u9084\u80fd\u5920\u5be6\u73fe\u8ca0\u8f09\u5747\u8861\u548c\u6545\u969c\u5bb9\u932f\u3002<\/p>\n<h3 id=\"%e5%88%86%e5%b8%83%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e5%84%aa%e5%8b%a2-qffICZsuIQ\">\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7684\u512a\u52e2<\/h3>\n<ul>\n<li><strong>\u64f4\u5c55\u6027\uff1a<\/strong>\u53ef\u4ee5\u901a\u904e\u589e\u52a0\u4f3a\u670d\u5668\u4f86\u8f15\u9b06\u64f4\u5c55\u7cfb\u7d71\u7684\u5bb9\u91cf\u3002<\/li>\n<li><strong>\u9ad8\u53ef\u7528\u6027\uff1a<\/strong>\u5373\u4f7f\u67d0\u500b\u4f3a\u670d\u5668\u6545\u969c\uff0c\u7cfb\u7d71\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u904b\u884c\u3002<\/li>\n<li><strong>\u6027\u80fd\u512a\u5316\uff1a<\/strong>\u901a\u904e\u6578\u64da\u5206\u7247\u548c\u8907\u88fd\u6280\u8853\uff0c\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%88%86%e5%b8%83%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%8a%80%e8%a1%93%e6%bc%94%e9%80%b2-qffICZsuIQ\">\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7684\u6280\u8853\u6f14\u9032<\/h2>\n<p>\u96a8\u8457\u9700\u6c42\u7684\u8b8a\u5316\uff0c\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u6280\u8853\u4e5f\u5728\u4e0d\u65b7\u6f14\u9032\u3002\u65e9\u671f\u7684\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7cfb\u7d71\u5982 Google \u7684 Bigtable \u548c Amazon \u7684 DynamoDB\uff0c\u70ba\u5f8c\u4f86\u7684 NoSQL \u6578\u64da\u5eab\u5960\u5b9a\u4e86\u57fa\u790e\u3002\u9019\u4e9b\u7cfb\u7d71\u5c08\u6ce8\u65bc\u9ad8\u53ef\u7528\u6027\u548c\u53ef\u64f4\u5c55\u6027\uff0c\u4e26\u4e14\u80fd\u5920\u8655\u7406\u975e\u7d50\u69cb\u5316\u6578\u64da\u3002<\/p>\n<h3 id=\"nosql-%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e8%88%88%e8%b5%b7-qffICZsuIQ\">NoSQL \u6578\u64da\u5eab\u7684\u8208\u8d77<\/h3>\n<p>NoSQL \u6578\u64da\u5eab\u7684\u51fa\u73fe\u662f\u5c0d\u50b3\u7d71\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u7684\u4e00\u7a2e\u88dc\u5145\u3002\u5b83\u5011\u4e0d\u518d\u4f9d\u8cf4\u65bc\u56fa\u5b9a\u7684\u6578\u64da\u7d50\u69cb\uff0c\u80fd\u5920\u9748\u6d3b\u5730\u8655\u7406\u5404\u7a2e\u6578\u64da\u985e\u578b\u3002\u5e38\u898b\u7684 NoSQL \u6578\u64da\u5eab\u5305\u62ec MongoDB\u3001Cassandra \u548c Redis \u7b49\u3002<\/p>\n<h4 id=\"%e7%af%84%e4%be%8b%ef%bc%9amongodb-%e7%9a%84%e4%bd%bf%e7%94%a8-qffICZsuIQ\">\u7bc4\u4f8b\uff1aMongoDB \u7684\u4f7f\u7528<\/h4>\n<pre><code>\nconst { MongoClient } = require('mongodb');\n\nasync function run() {\n    const client = new MongoClient('mongodb:\/\/localhost:27017');\n    try {\n        await client.connect();\n        const database = client.db('testdb');\n        const collection = database.collection('testcollection');\n        const doc = { name: \"Alice\", age: 25 };\n        const result = await collection.insertOne(doc);\n        console.log(`New listing created with the following id: ${result.insertedId}`);\n    } finally {\n        await client.close();\n    }\n}\n\nrun().catch(console.dir);\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-qffICZsuIQ\">\u7d50\u8ad6<\/h2>\n<p>\u5f9e\u55ae\u6a5f\u6578\u64da\u5eab\u5230\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u7684\u6f14\u9032\uff0c\u53cd\u6620\u4e86\u6280\u8853\u7684\u9032\u6b65\u548c\u5e02\u5834\u9700\u6c42\u7684\u8b8a\u5316\u3002\u96a8\u8457\u6578\u64da\u91cf\u7684\u6301\u7e8c\u589e\u9577\uff0c\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u5c07\u6210\u70ba\u672a\u4f86\u6578\u64da\u5b58\u5132\u7684\u4e3b\u6d41\u9078\u64c7\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u64f4\u5c55\u6027\u7684\u61c9\u7528\u4f86\u8aaa\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u67b6\u69cb\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f\u55ae\u6a5f\u9084\u662f\u5206\u5e03\u5f0f\u67b6\u69cb\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5f9e\u55ae\u6a5f\u6578\u64da\u5eab\u5230\u5206\u5e03\u5f0f\u6578\u64da\u5eab\u5b58\u5132\u7cfb\u7d71\u7684\u6f14\u9032\u904e\u7a0b\uff0c\u4e86\u89e3\u6280\u8853\u8b8a\u9769\u5982\u4f55\u63d0\u5347\u6578\u64da\u7ba1\u7406\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-153265","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153265","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=153265"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153265\/revisions"}],"predecessor-version":[{"id":153266,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153265\/revisions\/153266"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=153265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=153265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=153265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}