{"id":16244668,"url":"https://github.com/indexzero/changes","last_synced_at":"2026-03-15T21:04:58.988Z","repository":{"id":7453965,"uuid":"8797753","full_name":"indexzero/changes","owner":"indexzero","description":"A consistent, fault tolerant CouchDB _changes listener with pre-fetch support","archived":false,"fork":false,"pushed_at":"2014-08-14T00:58:49.000Z","size":167,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T22:24:02.982Z","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/indexzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-15T11:34:23.000Z","updated_at":"2017-04-30T07:34:47.000Z","dependencies_parsed_at":"2022-09-16T00:20:43.175Z","dependency_job_id":null,"html_url":"https://github.com/indexzero/changes","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fchanges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fchanges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fchanges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indexzero%2Fchanges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indexzero","download_url":"https://codeload.github.com/indexzero/changes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244483904,"owners_count":20460198,"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-10T14:20:11.975Z","updated_at":"2026-03-15T21:04:58.952Z","avatar_url":"https://github.com/indexzero.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# changes\n\nA consistent, fault tolerant CouchDB _changes listener with pre-fetch support.\n\n## Usage\n\n``` js\n  var Changes = require('changes');\n  \n  var changes = new Changes({\n    url: 'http://user:pass@127.0.0.1:5984/database',\n    timeout: {\n      max:  60000,\n      step: 5000\n    }\n  });\n  \n  //\n  // Dump changes as they come in.\n  //\n  changes.on('change', function (doc) {\n    console.dir(doc);\n  });\n  \n  //\n  // The callback will be called once a _changes\n  // connection has been established or with an\n  // error if the first connection fails.\n  //\n  changes.listen(function (err) {\n    if (err) {\n      console.log('Did not connect to _changes on first attempt');\n      console.dir(err);\n      changes.retry.enabled = false;\n      return process.exit(1);\n    }\n    \n    console.log('Listening for _changes');\n  });\n```\n\n## Pre-fetching Views\n\nOften when you establish a connection to `_changes` you also want to know about the other documents in a view before the current `update_seq`. This is supported like this:\n\n``` js\n  var Changes = require('changes');\n  \n  var changes = new Changes({\n    url: 'http://user:pass@127.0.0.1:5984/database',\n    views: {\n      'important': {\n        path: '_design/Some/_view/name',\n        query: { include_docs: true }\n      }\n    },\n    timeout: {\n      max:  60000,\n      step: 5000\n    }\n  });\n\n  //\n  // All rows from a queries view will be emitted\n  // in the `views:\u003cname\u003e` event **before** the\n  // `_changes` listener starts. \n  //\n  changes.on('views:important', function (rows) {\n    //\n    // Dump any existing \"important\" rows.\n    //\n    console.dir(rows);\n  });\n  \n  //\n  // Dump changes as they come in.\n  //\n  changes.on('change', function (doc) {\n    console.dir(doc);\n  });\n  \n  //\n  // The callback will be called once a _changes\n  // connection has been established or with an\n  // error if the first connection fails.\n  //\n  changes.listen(function (err) {\n    if (err) {\n      console.log('Did not connect to _changes on first attempt');\n      console.dir(err);\n      changes.retry.enabled = false;\n      return process.exit(1);\n    }\n    \n    console.log('Listening for _changes');\n  });\n```\n\n## Filtering `_changes` feed\nCouchDB's filtered `_changes` feed is documented [here](http://guide.couchdb.org/draft/notifications.html#filters).\nAll `Changes` needs to make use of it is a `filter` option:\n\n``` js\nvar Changes = require('changes');\n\nvar changes = new Changes({\n  url: 'http://user:pass@127.0.0.1:5984/database',\n  filter: 'app/filter'\n});\n```\n\n#### License: MIT\n#### Authors: [Bradley Meck](https://github.com/bmeck), [Maciej Malecki](https://github.com/mmalecki), [Charlie Robbins](https://github.com/indexzero)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexzero%2Fchanges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findexzero%2Fchanges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexzero%2Fchanges/lists"}