{"id":19041870,"url":"https://github.com/gsandf/rethinkdb-on-change","last_synced_at":"2026-05-08T18:30:21.717Z","repository":{"id":35012466,"uuid":"119392173","full_name":"gsandf/rethinkdb-on-change","owner":"gsandf","description":"🔌 Run a function when RethinkDB detects a change","archived":false,"fork":false,"pushed_at":"2023-01-04T01:20:46.000Z","size":924,"stargazers_count":0,"open_issues_count":18,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-02T07:25:19.757Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gsandf.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":"2018-01-29T14:19:36.000Z","updated_at":"2020-07-30T12:49:19.000Z","dependencies_parsed_at":"2023-01-15T11:59:42.970Z","dependency_job_id":null,"html_url":"https://github.com/gsandf/rethinkdb-on-change","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsandf%2Frethinkdb-on-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsandf%2Frethinkdb-on-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsandf%2Frethinkdb-on-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsandf%2Frethinkdb-on-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsandf","download_url":"https://codeload.github.com/gsandf/rethinkdb-on-change/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240100512,"owners_count":19747683,"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-11-08T22:32:59.264Z","updated_at":"2026-05-08T18:30:21.661Z","avatar_url":"https://github.com/gsandf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rethinkdb-on-change\n\n\u003e 🔌 Run a function when RethinkDB detects a [change](https://rethinkdb.com/docs/changefeeds/javascript/)\n\n[![Build Status](https://travis-ci.org/gsandf/rethinkdb-on-change.svg?branch=master)](https://travis-ci.org/gsandf/rethinkdb-on-change)\n[![Greenkeeper badge](https://badges.greenkeeper.io/gsandf/rethinkdb-on-change.svg)](https://greenkeeper.io/)\n\n**Don't [changefeeds](https://rethinkdb.com/docs/changefeeds/javascript/) already cover this?**\n\nYes, but we wanted a way of more easily looking for changes on multiple databases and tables with a whitelist/blacklist without writing the same thing multiple times.\n\nAlso, this comes with the feature of [debouncing](https://css-tricks.com/debouncing-throttling-explained-examples/) changes so you can run your logic only when needed.\n\n**✨ Features:**\n\n* **Simple:** specifying a connection and a function to run is all that's needed\n* **[Tested](https://travis-ci.org/gsandf/rethinkdb-on-change)**\n\n## Usage\n\n**Simple example:**\n\n```js\nimport dbOnChange from 'rethinkdb-on-change';\n\nfunction changeFn(newData) {\n  console.log('Received new data:', newData);\n}\n\nconst options = {\n  rethinkdb: { host: '127.0.0.1', port: 28015 },\n  tables: [{ db: 'megacorp', table: 'users' }]\n};\n\ndbOnChange(changeFn, options);\n```\n\n**Everything:**\n\n```js\nimport dbOnChange from 'rethinkdb-on-change';\n\nfunction changeFunction({\n  db, /* The database where the change occurred */\n  previousData, /* The old document data (if `previousData` is true).  Otherwise `undefined`. */\n  nextData, /* The new document data (if `nextData` is true).  Otherwise `undefined`. */\n  table /* The table where the change occurred */\n}) {\n\n}\n\nawait dbOnChange(changeFunction, {\n  // Connection details for the RethinkDB instance to be copied\n  // See `rethinkdbdash` (https://github.com/neumino/rethinkdbdash) for all possible options.\n  rethinkdb: {\n    // (optional) The host name. Defaults to '127.0.0.1'.\n    host: '127.0.0.1',\n    // (optional) The port to connect to the host to. Default is 28015.\n    port: 28015,\n    // (optional) protocol for connection (`http` or `https`).  Defaults to `http`.\n    protocol: 'http'\n  },\n\n  // (optional) If the document's new data should be a property of the argument\n  // sent to the change function.\n  nextData: false,\n\n  // (optional) If the document's previous data should be a property of the argument\n  // sent to the change function.\n  previousData: false,\n\n  // Tables to duplicate and watch for changes\n  tables: [\n    {\n      // Database containing table\n      db: 'megacorp',\n      // Table to copy\n      table: 'users'\n    }\n  ]\n});\n```\n\n## Install\n\nWith [Yarn](https://yarnpkg.com/en/) _or_ [npm](https://npmjs.org/) installed, run:\n\n```bash\nyarn add rethinkdb-on-change\n\n# ...or, if using `npm`\nnpm install rethinkdb-on-change\n```\n\n## See Also\n\n* [`rethinkdb-elasticsearch-stream`](https://github.com/gsandf/rethinkdb-elasticsearch-stream)\n* [RethinkDB changefeeds](https://rethinkdb.com/docs/changefeeds/javascript/)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsandf%2Frethinkdb-on-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsandf%2Frethinkdb-on-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsandf%2Frethinkdb-on-change/lists"}