{"id":15945796,"url":"https://github.com/ig3/couchdb","last_synced_at":"2025-06-10T17:35:33.105Z","repository":{"id":205333670,"uuid":"713700956","full_name":"ig3/couchdb","owner":"ig3","description":"A simple interface to CouchDB","archived":false,"fork":false,"pushed_at":"2024-07-08T21:16:59.000Z","size":181,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T11:17:58.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ig3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-03T04:05:08.000Z","updated_at":"2024-07-08T21:17:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2f7d5d5-d564-449a-bf6e-a7e1475aff89","html_url":"https://github.com/ig3/couchdb","commit_stats":null,"previous_names":["ig3/couchdb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fcouchdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fcouchdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fcouchdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fcouchdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ig3","download_url":"https://codeload.github.com/ig3/couchdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fcouchdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259118363,"owners_count":22807958,"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-07T09:06:44.202Z","updated_at":"2025-06-10T17:35:33.075Z","avatar_url":"https://github.com/ig3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ig3/couchdb\n\nSimple CouchDB client\n\n## Install\n\nUse [npm](https://npmjs.com/) to install.\n\n```sh\nnpm install @ig3/couchdb\n```\n## Getting started\n\nTo use `@ig3/couchdb` you need to connect to your CouchDB server:\n\n```js\nvar couch = require('@ig3/couchdb')({\n    hostname: 'localhost',\n    port:     5984,\n    protocol: 'http',\n    username: 'admin',\n    password: 'secret'\n});\n```\n\nTo get server meta information:\n\n```js\ncouch.get('/')\n.then(function(info) {\n    console.log(info);\n});\n```\n\n## Configuration\n\nTo configure @ig3/couchdb to access your CouchDB server:\n\n\n```js\nvar couch = require('@ig3/couchdb')({\n    hostname: 'localhost',\n    port:     5984,\n    protocol: 'http',\n    username: 'admin',\n    password: 'secret'\n});\n```\n\n\n## Methods\n\n### couch.db(opts)\n\nTo configure a connection to a database:\n\n```js\nvar db = couch.db({\n    db_name: 'mydb',\n    username:   'user',\n    password:   'mypassword'\n});\n```\n\nThe username and password are optional. If they are not provided, the \nusername and password of the server are used.\n\n### couch.get(path)\n\nHTTP GET against an arbitrary path on the server.\n\n```js\ncouch.get('/')\n.then(function(info) {\n  console.log('CouchDB meta information: ' + JSON.stringify(info));\n})\n.catch(function(err) {\n  console.log('GET / failed with: ', err);\n  throw err;\n});\n```\n\nThis does an HTTP GET on http://hostname:port/path.\n\nIf the path does not begin with '/' then '/' is prepended to the path.\n\n\n### couch.post(path,data)\n\nSend an HTTP POST request with an arbitrary path and data.\n\nPath is the path part of the URL to the server.\n\nData is and object that will be transformed to JSON and sent as the body \nof the POST request.\n\nReturns a promise that resolves to the CouchDB response or an error.\n\n```js\ncouch.post('/my_db/_bulk_docs', {\n  all_or_nothing: true,\n  docs: [{\n    _id: 'new_doc_id',\n    data: 'some data'\n  }]\n})\n.then(function(info) {\n  console.log('POST response: ' + JSON.stringify(info));\n})\n.catch(function(err) {\n  console.log('POST failed with: ', err);\n  throw err;\n});\n```\n\n\n## Database functions\n\n### db.changes(opts)\n\nRequests a continuous change feed and returns an event emitter that emits\nthe following event:\n\n* change - for each change received\n* error - if there is an error\n\nThe changes feed can be cancelled by calling the cancel() method.\n\n```js\nvar changes = db.changes();\n\nchanges.on('change', function(change) {\n    console.log('got a change ' + change);\n});\nchanges.on('error', function(error) {\n    console.log('oops');\n});\n\nchanges.cancel();\n```\n\n\n### db.get(path)\n\nHTTP GET from a path relative to the database.\n\n```js\nvar id = 'some_document_id';\ndb.get(id)\n.then(function(info) {\n    console.log('got doc: ' + JSON.stringify(info));\n})\n.catch(function(err) {\n    console.log('get ' + id + ' failed with: ', err);\n    throw err;\n});\n```\n\nThe request is to http://hostname:port/db_name/path.\n\nThe path may include query parameters:\n\n```js\nvar id = 'some_document_id';\ndb.get(id + '?meta=true')\n.then(function(info) {\n    console.log('got doc: ' + JSON.stringify(info));\n})\n.catch(function(err) {\n    console.log('get ' + id + ' failed with: ', err);\n    throw err;\n});\n```\n\n### db.post(path,data)\n\nSend an HTTP POST request with an arbitrary path and data.\n\nPath is appended to the database name.\n\nData is and object that will be transformed to JSON and sent as the body \nof the POST request.\n\nReturns a promise that resolves to the CouchDB response or an error.\n\n```js\ndb.post('_bulk_docs', {\n    all_or_nothing: true,\n    docs: [{\n        _id: 'new_doc_id',\n        data: 'some data'\n    }]\n})\n.then(function(info) {\n    console.log('POST response: ' + JSON.stringify(info));\n})\n.catch(function(err) {\n    console.log('POST failed with: ', err);\n    throw err;\n});\n```\n\n\n### db.purge(id)\n\nPurge the document with the given id from the database.\n\nReturns a promise wich resolves to an info object if the doc is purged\nor an error.\n\n\n```js\ndb.purge('some_id')\n.then(function(info) {\n    console.log('document was purged');\n})\n.catch(function(err) {\n    console.log('purge failed with ', err);\n});\n```\n\n\n### db.put(path, data)\n\nSubmit an HTTP PUT request to path, prefixed with database name, and\nwith given data.\n\nReturns a promise wich resolves to an info object or an error.\n\n```js\ndb.put('new_doc', {\n    _id: 'new_doc',\n    data: 'some data'\n})\n.then(function(info) {\n    console.log('put succeeded');\n})\n.catch(function(err) {\n    console.log('put failed with ', err);\n});\n```\n\n### db.soft_delete(doc)\n\nGiven a doc, set property deleted\\_time to current time and \\_deleted to true.\n\nReturns a promise that resolves to the updated version of the doc or\nan error.\n\n```js\ndb.get('some_doc')\n.then(function(doc) {\n    return db.soft_delete(doc);\n})\n.then(function(info) {\n    console.log('put succeeded');\n})\n.catch(function(err) {\n    console.log('put failed with ', err);\n});\n```\n\n## Changes\n\n### 2.0.0 - 20231104\n\n * Change the module export to the server factory.\n * Eliminate dependencies other than node core modules\n * Rewrite tests using multi-tape, tape and nock\n\n### 2.0.1 - 20240620\n * Minimize published package size\n * Update dependencies\n\n### 2.0.2 - 20240709\n * Rewrite tests using node:test and node:assert\n * Rewrite tests using tape and express instead of nock\n\n### 2.0.3 - WIP\n * Update dependencies\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fig3%2Fcouchdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fig3%2Fcouchdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fig3%2Fcouchdb/lists"}