{"id":16899711,"url":"https://github.com/bengotow/electron-rxdb","last_synced_at":"2025-03-22T10:30:54.410Z","repository":{"id":151930000,"uuid":"68731327","full_name":"bengotow/electron-RxDB","owner":"bengotow","description":"RxDB is a high-performance, observable object store built on top of SQLite \u0026 intended for database-driven Electron applications.","archived":false,"fork":false,"pushed_at":"2017-01-10T01:07:12.000Z","size":817,"stargazers_count":66,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-01T15:02:53.751Z","etag":null,"topics":["database","flux","observables","rx-js","rx-observable","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://bengotow.github.io/electron-RxDB","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bengotow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-09-20T16:26:44.000Z","updated_at":"2025-02-07T15:17:00.000Z","dependencies_parsed_at":"2023-05-16T13:30:31.543Z","dependency_job_id":null,"html_url":"https://github.com/bengotow/electron-RxDB","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengotow%2Felectron-RxDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengotow%2Felectron-RxDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengotow%2Felectron-RxDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengotow%2Felectron-RxDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bengotow","download_url":"https://codeload.github.com/bengotow/electron-RxDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244198350,"owners_count":20414443,"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":["database","flux","observables","rx-js","rx-observable","sqlite","sqlite3"],"created_at":"2024-10-13T17:49:53.162Z","updated_at":"2025-03-22T10:30:54.378Z","avatar_url":"https://github.com/bengotow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxDB\n\n\u003ca href=\"https://travis-ci.org/bengotow/electron-RxDB\"\u003e![](https://travis-ci.org/bengotow/electron-RxDB.svg?branch=master)\u003c/a\u003e\n\nRxDB is a high-performance, observable object store built on top of SQLite.\nRxDB draws inspiration from CoreData and Relay and is intended for\ndatabase-driven Electron applications. It was originally built for\nthe [Nylas N1](https://github.com/nylas/N1) mail client.\n\nView the [API Reference](https://bengotow.github.io/electron-RxDB) on GitHub Pages.\n\n## An *Observable* Object Store\n\n- RxDB queries are [Rx.JS Observables](https://github.com/Reactive-Extensions/RxJS).\nSimply create queries and declaratively\nbind them to your application's views. Queries internally subscribe to the\ndatabase, watch for changes, and vend new versions of their result sets as\nnecessary. They've been heavily optimized for performance, and often update\nwithout making SQL queries.\n\n- RxDB databases are event emitters. Want to keep things in sync with your data?\nAdd listeners to refresh application state as objects are saved and removed.\n\nExample: Nylas N1 uses a Flux architecture. Many of the Flux Stores in the\napplication vend state derived from an RxDB database containing the user's\nmail data. When an object is written to the database, it emits and event,\nand stores (like the UnreadCountStore) can evaluate whether to update\ndownstream application state.\n\n\n## Basic Usage\n\n### Defining a Model:\n\n```js\nexport default class Note extends Model {\n  static attributes = Object.assign(Model.attributes, {\n    name: Attributes.String({\n      modelKey: 'name',\n      jsonKey: 'name',\n      queryable: true,\n    }),\n    content: Attributes.String({\n      modelKey: 'content',\n      jsonKey: 'content',\n    }),\n    createdAt: Attributes.DateTime({\n      modelKey: 'createdAt',\n      jsonKey: 'createdAt',\n      queryable: true,\n    }),\n  });\n}\n```\n\n### Saving a Model:\n\n```js\nconst note = new Note({\n  name: 'Untitled',\n  content: 'Write your note here!',\n  createdAt: new Date(),\n});\ndatabase.inTransaction((t) =\u003e {\n  return t.persistModel(note);\n});\n```\n\n### Querying for Models:\n\n```js\ndatabase\n  .findAll(Note)\n  .where({name: 'Untitled'})\n  .order(Note.attributes.createdAt.descending())\n  .then((notes) =\u003e {\n  // got some notes!\n})\n```\n\n### Observing a query:\n\n```js\ncomponentDidMount() {\n  const query = database\n    .findAll(Note)\n    .where({name: 'Untitled'})\n    .order(Note.attributes.createdAt.descending())\n\n  this._subscription = query.observe().subscribe((items) =\u003e {\n    this.setState({items});\n  });\n}\n```\n\n## Features\n\n- Models:\n  + Definition via ES2016 classes extending `RxDB.Model`\n  + Out of the box support for JSON serialization\n  + Easy attribute definition and validation\n  + Automatic schema generation based on `queryable` fields\n  + Support for splitting object data across tables, keeping SQLite row size small\n\n- Queries:\n  + Results via a Promise API. (`query.then((results) =\u003e ...)``)\n  + Live results via an Rx.JS Observable API. (`query.observable().subscribe((results) =\u003e ...)`)\n  + Clean query syntax inspired by ActiveRecord and NSPredicate\n  + Support for basic relationships and retrieving of joined objects\n  + Full-text search powered by SQLite's FTS5\n\n- Database:\n  + ChangeRecord objects emitted for every modification of data\n  + Changes bridged across window processes for multi-window apps\n  + Support for opening multiple databases simultaneously\n\n- High test coverage!\n\n## FAQ\n### How does this fit in to Flux / Redux / etc?\n\nRxDB is not intended to be a replacement for [Redux](https://github.com/reactjs/redux)\nor other application state frameworks, and works great alongside them!\n\nRedux is ideal for storing small bits of state, like the user's current selection.\nIn a typical RxDB application, this application state determines the views that\nare displayed and the queries that are declaratively bound to those views. Individual\ncomponents build queries and display the resulting data.\n\n### Wait, I can't make `UPDATE` queries?\n\nRxDB exposes an ActiveRecord-style query syntax, but only for fetching models.\nRxDB's powerful observable queries, modification hooks, and other features\ndepend on application code being able to see every change to every object.\n\nQueries like `UPDATE Note SET read = 1 WHERE ...` allow you to make\nchanges with unknown effects, and are explicitly not allowed.\n(Every live query of a Note would need to be re-run following that change!)\nInstead of expanding support for arbitrary queries, RxDB focuses on making\nreading and saving objects *blazing fast*, so doing a query, modifying a few\nhundred matches, and saving them back is perfectly fine.\n\n## Examples \u0026 API Reference\n\n\u003cimg src=\"https://raw.githubusercontent.com/bengotow/electron-RxDB/master/example/screenshot.png\" /\u003e\n\nThe example \"Notes\" app may be the best place to get started, but a full\n[API Reference](https://bengotow.github.io/electron-RxDB) is available\non GitHub Pages.\n\n## Contributing\n\n#### Running the Notes Example\n\n```bash\nnpm install\ncd ./example\nnpm install\nnpm start\n```\n\n#### Running the Tests\n\nRxDB's tests are written in [Jasmine 2](jasmine.github.io/2.5/introduction.html)\nand run in a tiny Electron application for consistency with the target environment.\nTo run the tests, use `npm test`:\n\n```bash\nnpm install\nnpm test\n```\n\nYou can skip certain tests (temporarily) with `xit` and `xdescribe`,\nor focus on only certain tests with `fit` and `fdescribe`.\n\n#### Running the Linter\n\n```\nnpm install\nnpm run lint\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbengotow%2Felectron-rxdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbengotow%2Felectron-rxdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbengotow%2Felectron-rxdb/lists"}