{"id":16906588,"url":"https://github.com/rsms/node-couchdb-min","last_synced_at":"2025-09-26T15:04:01.808Z","repository":{"id":850328,"uuid":"579692","full_name":"rsms/node-couchdb-min","owner":"rsms","description":"Simplistic CouchDB client with a minimal level of abstraction and connection pooling.","archived":false,"fork":false,"pushed_at":"2010-05-19T12:53:51.000Z","size":102,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T15:26:24.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-03-25T21:09:11.000Z","updated_at":"2022-11-17T21:15:53.000Z","dependencies_parsed_at":"2022-08-16T11:10:30.569Z","dependency_job_id":null,"html_url":"https://github.com/rsms/node-couchdb-min","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fnode-couchdb-min","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fnode-couchdb-min/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fnode-couchdb-min/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fnode-couchdb-min/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsms","download_url":"https://codeload.github.com/rsms/node-couchdb-min/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429831,"owners_count":21101903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T18:43:27.218Z","updated_at":"2025-09-26T15:04:01.722Z","avatar_url":"https://github.com/rsms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Simplistic CouchDB client with a minimal level of abstraction\n\n*Explanation by example:*\n\nSimply create a new instance, passing database name (or complex options):\n\n    var db = new exports.Db('blog-posts');\n    var slaveDb = new exports.Db({db:'blog-posts', host:'dbslave.local'});\n\nA db object is merely a gateway for dispatching requests to a particular server. The following GETs a document with the key \"foo\" in the database \"blog-posts\":\n\n    db.get('foo', function(err, result) {\n      if (err) sys.error(err.stack);\n      sys.log('document -\u003e '+sys.inspect(result));\n    });\n\nThe above call is equivalent to this request:\n\n    GET /blog-posts/foo HTTP/1.1\n    Host: localhost\n    Connection: Keep-Alive\n\nThere are very few helper methods, simply because db.get(\"/action\") is\nverbose enough and close to the actual CouchDB API. however, some common\nfunctionality is available at a higher level, for instance \"_all_docs\":\n\n    db.allDocs([\"foo\", \"bar\"], function(err, docs) {\n      if (err) sys.error(err.stack);\n      sys.log('documents -\u003e '+sys.inspect(docs));\n    });\n\nThe above is roughly equivalent to this lower level call:\n\n    db.post('_all_docs?include_docs=true', {keys:[\"foo\", \"bar\"]},\n      function(err, result)\n    {\n      if (err) return sys.error(err.stack);\n      var docs = {};\n      result.rows.forEach(function(row){ docs[row.id] = row.doc||row.value; });\n      sys.log('documents -\u003e '+sys.inspect(docs));\n    });\n\nRequesting stuff outside of a \"database\" is possible in multiple ways. a)\nBy creating an instance without database/namespace. The resulting handle have\nno prefix and thus all requests roots themselves at \"/\". However, as a\nconvenience mechanism, you can prefix paths with a \"/\" character to indicate\nthe path is absolute:\n\n    db.get('/_all_dbs', function(err, result) {\n      if (err) sys.error(err.stack);\n      sys.log('databases -\u003e '+sys.inspect(result));\n    });\n\n\nAll calls are asynchronous. There's a connection pool used in the background,\nmainly taking case of two things:\n\n1. keeping ~1 alive connection for low latency in low traffic environments.\n\n2. limiting the number of concurrent requests -- when the limit is hit,\n   requests will be held in a queue until a connection becomes available.\n\nIf you require monotonicity -- things happening in a sequential order -- just do like you do with all other async calls:\n\n    db.get('/_uuids?count=1', function(err, result){\n      if (err) return sys.error(err.stack);\n      var _id = result.uuids[0];\n      db.put(_id, {\"hello\": \"world\"}, function(err, result) {\n        if (err) return sys.error(err.stack);\n        db.get(_id, function(err, doc) {\n          if (err) return sys.error(err.stack);\n          sys.log('Created and retrieved '+_id+' -\u003e '+sys.inspect(doc));\n        });\n      });\n    });\n\n\u003e **Looking for something high-level?** -- Check out [node-couchdb](http://github.com/felixge/node-couchdb) which provides a javascript API layer on top of the CouchDB API.\n\nMore detailed documentation is available in-line the `couchdb.js` file.\n\n## Requirements\n\n- [node](http://nodejs.org/) `\u003e=0.1.32`\n\n## MIT license\n\nCopyright (c) 2010 Rasmus Andersson \u003chttp://hunch.se/\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n## TODO\n\n- Optional response cache (with memory limit) based on etags.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fnode-couchdb-min","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsms%2Fnode-couchdb-min","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fnode-couchdb-min/lists"}