{"id":152911,"date":"2024-11-02T03:03:20","date_gmt":"2024-11-01T19:03:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/152911\/"},"modified":"2024-11-02T03:03:21","modified_gmt":"2024-11-01T19:03:21","slug":"%e5%88%9d%e7%aa%ba-nosql-%e4%b8%96%e7%95%8c-%e9%96%8b%e6%ba%90-couchdb-%e6%96%b0%e6%89%8b%e5%85%a5%e9%96%80","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/152911\/","title":{"rendered":"\u521d\u7aba NoSQL \u4e16\u754c \u958b\u6e90 CouchDB \u65b0\u624b\u5165\u9580"},"content":{"rendered":"<h1 id=\"%e5%88%9d%e7%aa%ba-nosql-%e4%b8%96%e7%95%8c-%e9%96%8b%e6%ba%90-couchdb-%e6%96%b0%e6%89%8b%e5%85%a5%e9%96%80-JhAwtpSaZV\">\u521d\u7aba NoSQL \u4e16\u754c \u958b\u6e90 CouchDB \u65b0\u624b\u5165\u9580<\/h1>\n<p>\u96a8\u8457\u6578\u64da\u91cf\u7684\u6025\u5287\u589e\u9577\uff0c\u50b3\u7d71\u7684\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u5728\u67d0\u4e9b\u61c9\u7528\u5834\u666f\u4e2d\u9010\u6f38\u986f\u5f97\u529b\u4e0d\u5f9e\u5fc3\u3002\u9019\u4fc3\u4f7f\u4e86 NoSQL \u6578\u64da\u5eab\u7684\u8208\u8d77\uff0c\u5176\u4e2d CouchDB \u4f5c\u70ba\u4e00\u500b\u958b\u6e90\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u56e0\u5176\u7368\u7279\u7684\u7279\u6027\u548c\u9748\u6d3b\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u95dc\u6ce8\u3002\u672c\u6587\u5c07\u5e36\u60a8\u521d\u6b65\u4e86\u89e3 CouchDB \u7684\u57fa\u672c\u6982\u5ff5\u3001\u7279\u6027\u53ca\u5176\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"nosql-%e6%95%b8%e6%93%9a%e5%ba%ab%e6%a6%82%e8%bf%b0-JhAwtpSaZV\">NoSQL \u6578\u64da\u5eab\u6982\u8ff0<\/h2>\n<p>NoSQL\uff08Not Only SQL\uff09\u6578\u64da\u5eab\u662f\u4e00\u985e\u4e0d\u4f7f\u7528\u50b3\u7d71\u95dc\u4fc2\u6a21\u578b\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u3002\u5b83\u5011\u901a\u5e38\u7528\u65bc\u8655\u7406\u5927\u898f\u6a21\u7684\u6578\u64da\u96c6\uff0c\u4e26\u63d0\u4f9b\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u548c\u6aa2\u7d22\u80fd\u529b\u3002NoSQL \u6578\u64da\u5eab\u7684\u4e3b\u8981\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\uff1a\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u5982\u6587\u6a94\u3001\u9375\u503c\u3001\u5217\u65cf\u548c\u5716\u5f62\u3002<\/li>\n<li>\u53ef\u64f4\u5c55\u6027\uff1a\u80fd\u5920\u8f15\u9b06\u5730\u64f4\u5c55\u4ee5\u8655\u7406\u5927\u91cf\u6578\u64da\u3002<\/li>\n<li>\u9ad8\u6027\u80fd\uff1a\u5728\u8b80\u53d6\u548c\u5beb\u5165\u64cd\u4f5c\u4e0a\u901a\u5e38\u6bd4\u50b3\u7d71\u6578\u64da\u5eab\u66f4\u5feb\u3002<\/li>\n<\/ul>\n<h2 id=\"couchdb-%e7%b0%a1%e4%bb%8b-JhAwtpSaZV\">CouchDB \u7c21\u4ecb<\/h2>\n<p>CouchDB \u662f\u4e00\u500b\u57fa\u65bc\u6587\u6a94\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u4f7f\u7528 JSON \u683c\u5f0f\u4f86\u5b58\u5132\u6578\u64da\uff0c\u4e26\u901a\u904e HTTP \u5354\u8b70\u9032\u884c\u6578\u64da\u7684\u8b80\u53d6\u548c\u5beb\u5165\u3002CouchDB \u7684\u8a2d\u8a08\u7406\u5ff5\u662f\u7c21\u55ae\u6613\u7528\uff0c\u4e26\u4e14\u652f\u6301\u591a\u7a2e\u5e73\u53f0\u3002\u5176\u4e3b\u8981\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u6587\u6a94\u5c0e\u5411\uff1a<\/strong>\u6578\u64da\u4ee5 JSON \u6587\u6a94\u7684\u5f62\u5f0f\u5b58\u5132\uff0c\u9019\u4f7f\u5f97\u6578\u64da\u7d50\u69cb\u66f4\u52a0\u9748\u6d3b\u3002<\/li>\n<li><strong>RESTful API\uff1a<\/strong>\u901a\u904e HTTP \u5354\u8b70\u9032\u884c\u64cd\u4f5c\uff0c\u65b9\u4fbf\u8207\u5176\u4ed6\u61c9\u7528\u96c6\u6210\u3002<\/li>\n<li><strong>\u591a\u7248\u672c\u63a7\u5236\uff1a<\/strong>\u652f\u6301 MVCC\uff08\u591a\u7248\u672c\u4e26\u767c\u63a7\u5236\uff09\uff0c\u63d0\u9ad8\u4e86\u6578\u64da\u7684\u53ef\u9760\u6027\u548c\u4e00\u81f4\u6027\u3002<\/li>\n<li><strong>\u5206\u4f48\u5f0f\u67b6\u69cb\uff1a<\/strong>\u652f\u6301\u6578\u64da\u7684\u5206\u4f48\u5f0f\u5b58\u5132\uff0c\u9069\u5408\u5927\u898f\u6a21\u61c9\u7528\u3002<\/li>\n<\/ul>\n<h2 id=\"couchdb-%e7%9a%84%e5%ae%89%e8%a3%9d%e8%88%87%e9%85%8d%e7%bd%ae-JhAwtpSaZV\">CouchDB \u7684\u5b89\u88dd\u8207\u914d\u7f6e<\/h2>\n<p>\u8981\u958b\u59cb\u4f7f\u7528 CouchDB\uff0c\u9996\u5148\u9700\u8981\u5728\u60a8\u7684\u7cfb\u7d71\u4e0a\u5b89\u88dd\u5b83\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo apt-get update\nsudo apt-get install couchdb\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u8a2a\u554f <code>http:\/\/127.0.0.1:5984\/<\/code> \u4f86\u6aa2\u67e5 CouchDB \u662f\u5426\u904b\u884c\u6b63\u5e38\u3002\u60a8\u61c9\u8a72\u6703\u770b\u5230\u4e00\u500b\u5305\u542b\u7248\u672c\u4fe1\u606f\u7684 JSON \u97ff\u61c9\u3002<\/p>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e6%93%8d%e4%bd%9c%e7%a4%ba%e4%be%8b-JhAwtpSaZV\">\u57fa\u672c\u64cd\u4f5c\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7684 CouchDB \u64cd\u4f5c\u793a\u4f8b\uff0c\u5305\u62ec\u5275\u5efa\u6578\u64da\u5eab\u3001\u6dfb\u52a0\u6587\u6a94\u548c\u67e5\u8a62\u6587\u6a94\u3002<\/p>\n<h3 id=\"%e5%89%b5%e5%bb%ba%e6%95%b8%e6%93%9a%e5%ba%ab-JhAwtpSaZV\">\u5275\u5efa\u6578\u64da\u5eab<\/h3>\n<pre><code>curl -X PUT http:\/\/127.0.0.1:5984\/my_database\n<\/code><\/pre>\n<h3 id=\"%e6%b7%bb%e5%8a%a0%e6%96%87%e6%aa%94-JhAwtpSaZV\">\u6dfb\u52a0\u6587\u6a94<\/h3>\n<pre><code>curl -X POST http:\/\/127.0.0.1:5984\/my_database -d '{\"name\": \"Alice\", \"age\": 30}'\n<\/code><\/pre>\n<h3 id=\"%e6%9f%a5%e8%a9%a2%e6%96%87%e6%aa%94-JhAwtpSaZV\">\u67e5\u8a62\u6587\u6a94<\/h3>\n<pre><code>curl -X GET http:\/\/127.0.0.1:5984\/my_database\/_all_docs?include_docs=true\n<\/code><\/pre>\n<p>\u9019\u4e9b\u57fa\u672c\u64cd\u4f5c\u5c55\u793a\u4e86\u5982\u4f55\u8207 CouchDB \u9032\u884c\u4ea4\u4e92\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u9032\u4e00\u6b65\u64f4\u5c55\u548c\u81ea\u5b9a\u7fa9\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-JhAwtpSaZV\">\u7e3d\u7d50<\/h2>\n<p>CouchDB \u4f5c\u70ba\u4e00\u500b\u958b\u6e90\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u9748\u6d3b\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u9069\u5408\u5404\u7a2e\u61c9\u7528\u5834\u666f\u3002\u7121\u8ad6\u662f\u5c0f\u578b\u9805\u76ee\u9084\u662f\u5927\u578b\u7cfb\u7d71\uff0cCouchDB \u90fd\u80fd\u5920\u6eff\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002\u5c0d\u65bc\u5e0c\u671b\u63a2\u7d22 NoSQL \u4e16\u754c\u7684\u958b\u767c\u8005\u4f86\u8aaa\uff0cCouchDB \u662f\u4e00\u500b\u4e0d\u932f\u7684\u9078\u64c7\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u4f86\u904b\u884c\u60a8\u7684 CouchDB \u5be6\u4f8b\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u52a9\u60a8\u8f15\u9b06\u4e0a\u624b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u521d\u7aba NoSQL \u4e16\u754c\uff0c\u5b78\u7fd2\u958b\u6e90 CouchDB \u7684\u57fa\u790e\u77e5\u8b58\uff0c\u9069\u5408\u65b0\u624b\u5165\u9580\uff0c\u5feb\u901f\u638c\u63e1\u8cc7\u6599\u5eab\u7ba1\u7406\u6280\u5de7\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-152911","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152911","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=152911"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152911\/revisions"}],"predecessor-version":[{"id":152912,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152911\/revisions\/152912"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=152911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=152911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=152911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}