{"id":190352,"date":"2024-11-12T11:52:24","date_gmt":"2024-11-12T03:52:24","guid":{"rendered":"https:\/\/server.hk\/cnblog\/190352\/"},"modified":"2024-11-12T11:52:25","modified_gmt":"2024-11-12T03:52:25","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%98%e5%84%b2%e6%8a%80%e5%b7%a7%e5%88%86%e4%ba%ab-%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%b8%e6%93%9a%e5%ba%ab","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/190352\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6578\u64da\u5eab\u5b58\u5132\u6280\u5de7\u5206\u4eab (\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6578\u64da\u5eab\u5b58\u653e)"},"content":{"rendered":"<h1 id=\"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%98%e5%84%b2%e6%8a%80%e5%b7%a7%e5%88%86%e4%ba%ab-jQcTwZBkzw\">\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6578\u64da\u5eab\u5b58\u5132\u6280\u5de7\u5206\u4eab<\/h1>\n<p>\u96a8\u8457\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u666e\u53ca\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u958b\u767c\u8005\u958b\u59cb\u95dc\u6ce8\u5982\u4f55\u6709\u6548\u5730\u7ba1\u7406\u548c\u5b58\u5132\u6578\u64da\u3002\u6578\u64da\u5eab\u7684\u9078\u64c7\u548c\u4f7f\u7528\u5c0d\u65bc\u5c0f\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u7528\u6236\u9ad4\u9a57\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u5c07\u5206\u4eab\u4e00\u4e9b\u95dc\u65bc\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6578\u64da\u5eab\u5b58\u5132\u7684\u6280\u5de7\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u597d\u5730\u7ba1\u7406\u6578\u64da\u3002<\/p>\n<h2 id=\"%e9%81%b8%e6%93%87%e5%90%88%e9%81%a9%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab-jQcTwZBkzw\">\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab<\/h2>\n<p>\u5728\u9078\u64c7\u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u9700\u8981\u8003\u616e\u591a\u500b\u56e0\u7d20\uff0c\u5305\u62ec\u6578\u64da\u7684\u7d50\u69cb\u3001\u5b58\u5132\u9700\u6c42\u3001\u67e5\u8a62\u6027\u80fd\u7b49\u3002\u5e38\u898b\u7684\u6578\u64da\u5eab\u9078\u64c7\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u4e91\u6578\u64da\u5eab\uff1a<\/strong>\u5982\u5fae\u4fe1\u63d0\u4f9b\u7684\u4e91\u958b\u767c\u6578\u64da\u5eab\uff0c\u9069\u5408\u5c0f\u578b\u61c9\u7528\uff0c\u652f\u6301\u81ea\u52d5\u64f4\u5c55\u548c\u9ad8\u53ef\u7528\u6027\u3002<\/li>\n<li><strong>\u95dc\u4fc2\u578b\u6578\u64da\u5eab\uff1a<\/strong>\u5982MySQL\uff0c\u9069\u5408\u9700\u8981\u8907\u96dc\u67e5\u8a62\u548c\u4e8b\u52d9\u8655\u7406\u7684\u61c9\u7528\u3002<\/li>\n<li><strong>NoSQL\u6578\u64da\u5eab\uff1a<\/strong>\u5982MongoDB\uff0c\u9069\u5408\u5b58\u5132\u975e\u7d50\u69cb\u5316\u6578\u64da\uff0c\u9748\u6d3b\u6027\u9ad8\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e7%b5%90%e6%a7%8b%e8%a8%ad%e8%a8%88-jQcTwZBkzw\">\u6578\u64da\u7d50\u69cb\u8a2d\u8a08<\/h2>\n<p>\u826f\u597d\u7684\u6578\u64da\u7d50\u69cb\u8a2d\u8a08\u80fd\u5920\u63d0\u9ad8\u6578\u64da\u5b58\u53d6\u6548\u7387\u3002\u958b\u767c\u8005\u61c9\u6839\u64da\u696d\u52d9\u9700\u6c42\u8a2d\u8a08\u6578\u64da\u8868\uff0c\u4e26\u8003\u616e\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li><strong>\u6b63\u898f\u5316\uff1a<\/strong>\u907f\u514d\u6578\u64da\u5197\u9918\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u4e00\u81f4\u6027\u3002<\/li>\n<li><strong>\u7d22\u5f15\uff1a<\/strong>\u70ba\u5e38\u7528\u67e5\u8a62\u5b57\u6bb5\u5efa\u7acb\u7d22\u5f15\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002<\/li>\n<li><strong>\u5206\u5340\uff1a<\/strong>\u5c0d\u65bc\u5927\u6578\u64da\u91cf\u7684\u8868\uff0c\u53ef\u4ee5\u8003\u616e\u5206\u5340\u5b58\u5132\uff0c\u63d0\u5347\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ad%98%e5%8f%96%e5%84%aa%e5%8c%96-jQcTwZBkzw\">\u6578\u64da\u5b58\u53d6\u512a\u5316<\/h2>\n<p>\u5728\u6578\u64da\u5b58\u53d6\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u63a1\u53d6\u4ee5\u4e0b\u512a\u5316\u63aa\u65bd\uff1a<\/p>\n<ul>\n<li><strong>\u6279\u91cf\u64cd\u4f5c\uff1a<\/strong>\u5c0d\u65bc\u9700\u8981\u63d2\u5165\u6216\u66f4\u65b0\u5927\u91cf\u6578\u64da\u7684\u60c5\u6cc1\uff0c\u4f7f\u7528\u6279\u91cf\u64cd\u4f5c\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li><strong>\u7de9\u5b58\u6a5f\u5236\uff1a<\/strong>\u4f7f\u7528\u7de9\u5b58\u6280\u8853\uff08\u5982Redis\uff09\u4f86\u6e1b\u5c11\u5c0d\u6578\u64da\u5eab\u7684\u76f4\u63a5\u8a2a\u554f\uff0c\u63d0\u5347\u97ff\u61c9\u901f\u5ea6\u3002<\/li>\n<li><strong>\u7570\u6b65\u8655\u7406\uff1a<\/strong>\u5c0d\u65bc\u4e0d\u9700\u8981\u5373\u6642\u53cd\u994b\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u7570\u6b65\u8655\u7406\uff0c\u6e1b\u5c11\u7528\u6236\u7b49\u5f85\u6642\u9593\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ae%89%e5%85%a8%e6%80%a7-jQcTwZBkzw\">\u6578\u64da\u5b89\u5168\u6027<\/h2>\n<p>\u6578\u64da\u5b89\u5168\u662f\u958b\u767c\u8005\u5fc5\u9808\u91cd\u8996\u7684\u554f\u984c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4fdd\u8b77\u6578\u64da\u5b89\u5168\u7684\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u52a0\u5bc6\uff1a<\/strong>\u5c0d\u654f\u611f\u6578\u64da\u9032\u884c\u52a0\u5bc6\u5b58\u5132\uff0c\u9632\u6b62\u6578\u64da\u6d29\u9732\u3002<\/li>\n<li><strong>\u6b0a\u9650\u63a7\u5236\uff1a<\/strong>\u8a2d\u7f6e\u5408\u7406\u7684\u6578\u64da\u8a2a\u554f\u6b0a\u9650\uff0c\u78ba\u4fdd\u53ea\u6709\u6388\u6b0a\u7528\u6236\u624d\u80fd\u8a2a\u554f\u7279\u5b9a\u6578\u64da\u3002<\/li>\n<li><strong>\u5b9a\u671f\u5099\u4efd\uff1a<\/strong>\u5b9a\u671f\u5c0d\u6578\u64da\u9032\u884c\u5099\u4efd\uff0c\u4ee5\u9632\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%af%a6%e4%be%8b%e4%bb%a3%e7%a2%bc-jQcTwZBkzw\">\u5be6\u4f8b\u4ee3\u78bc<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u4e91\u958b\u767c\u6578\u64da\u5eab\u9032\u884c\u6578\u64da\u7684\u589e\u522a\u6539\u67e5\uff1a<\/p>\n<pre><code>\n\/\/ \u521d\u59cb\u5316\u4e91\u958b\u767c\nwx.cloud.init({\n  env: 'your-env-id'\n});\n\n\/\/ \u6dfb\u52a0\u6578\u64da\nconst db = wx.cloud.database();\ndb.collection('your-collection').add({\n  data: {\n    name: 'example',\n    age: 25\n  },\n  success: res =&gt; {\n    console.log('\u6578\u64da\u6dfb\u52a0\u6210\u529f', res);\n  },\n  fail: err =&gt; {\n    console.error('\u6578\u64da\u6dfb\u52a0\u5931\u6557', err);\n  }\n});\n\n\/\/ \u67e5\u8a62\u6578\u64da\ndb.collection('your-collection').get({\n  success: res =&gt; {\n    console.log('\u67e5\u8a62\u7d50\u679c', res.data);\n  }\n});\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-jQcTwZBkzw\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u958b\u767c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6642\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u3001\u8a2d\u8a08\u826f\u597d\u7684\u6578\u64da\u7d50\u69cb\u3001\u512a\u5316\u6578\u64da\u5b58\u53d6\u4ee5\u53ca\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u90fd\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u9019\u4e9b\u6280\u5de7\u4e0d\u50c5\u80fd\u63d0\u9ad8\u5c0f\u7a0b\u5e8f\u7684\u6027\u80fd\uff0c\u9084\u80fd\u63d0\u5347\u7528\u6236\u9ad4\u9a57\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u4e86\u89e3\u5982\u4f55\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u4f86\u652f\u6301\u60a8\u7684\u61c9\u7528\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6578\u64da\u5eab\u5b58\u5132\u6280\u5de7\uff0c\u63d0\u5347\u6578\u64da\u7ba1\u7406\u6548\u7387\uff0c\u512a\u5316\u6027\u80fd\uff0c\u78ba\u4fdd\u5b89\u5168\u6027\u8207\u7a69\u5b9a\u6027\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-190352","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190352","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=190352"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190352\/revisions"}],"predecessor-version":[{"id":190353,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190352\/revisions\/190353"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=190352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=190352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=190352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}