All Projects → bengotow → electron-RxDB

bengotow / electron-RxDB

Licence: GPL-3.0 license
RxDB is a high-performance, observable object store built on top of SQLite & intended for database-driven Electron applications.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to electron-RxDB

ZXDataHandle
简单易用的数据转换和存储框架,支持一行代码将模型、模型数组、Json字符串、字典互转;支持模型映射到sqlite3数据库,无需书写sql
Stars: ✭ 13 (-80.88%)
Mutual labels:  sqlite3
observer-spy
This library makes RxJS Observables testing easy!
Stars: ✭ 310 (+355.88%)
Mutual labels:  observables
sqlite-nio
Non-blocking wrapper for libsqlite3-dev using SwiftNIO
Stars: ✭ 33 (-51.47%)
Mutual labels:  sqlite3
realt
Realt is a new way to work with Redux inspired by Alt
Stars: ✭ 41 (-39.71%)
Mutual labels:  flux
ionic2-PreDB
Simple Ionic 2+ with pre-populated database starter project
Stars: ✭ 14 (-79.41%)
Mutual labels:  sqlite3
ng-effects
Reactivity system for Angular. https://ngfx.io
Stars: ✭ 46 (-32.35%)
Mutual labels:  observables
nanoflux-fusion
Redux-like extension for Nanoflux
Stars: ✭ 15 (-77.94%)
Mutual labels:  flux
ndb.nim
A db_sqlite fork with a proper typing
Stars: ✭ 38 (-44.12%)
Mutual labels:  sqlite3
DaggerFlux.jl
Distributed computation of differentiation pipelines to use multiple workers, devices, GPU, etc. since Julia wasn't fast enough already
Stars: ✭ 57 (-16.18%)
Mutual labels:  flux
SQLiteHelper
🗄 This project comes in handy when you want to write a sql statement easily and smarter.
Stars: ✭ 57 (-16.18%)
Mutual labels:  sqlite3
nifi-influxdb-bundle
InfluxDB Processors For Apache NiFi
Stars: ✭ 30 (-55.88%)
Mutual labels:  flux
observable-profiler
Tracks new & disposed Observable subscriptions
Stars: ✭ 41 (-39.71%)
Mutual labels:  observables
CMU-15445
https://www.jianshu.com/nb/36265841
Stars: ✭ 220 (+223.53%)
Mutual labels:  sqlite3
hybrid-disk-cache
A hybrid disk cache library that utilized both the solid SQLite3 and file system.
Stars: ✭ 19 (-72.06%)
Mutual labels:  sqlite3
sqlite-kit
Non-blocking SQLite client library with SQL builder built on SwiftNIO
Stars: ✭ 51 (-25%)
Mutual labels:  sqlite3
SQLiteReverse
腾讯课堂《SQLite数据库逆向分析》
Stars: ✭ 118 (+73.53%)
Mutual labels:  sqlite3
fluxml.github.io
Flux Website
Stars: ✭ 20 (-70.59%)
Mutual labels:  flux
ObservableComputations
Cross-platform .NET library for computations whose arguments and results are objects that implement INotifyPropertyChanged and INotifyCollectionChanged (ObservableCollection) interfaces.
Stars: ✭ 94 (+38.24%)
Mutual labels:  rx-observable
grafito
Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
Stars: ✭ 95 (+39.71%)
Mutual labels:  sqlite3
AC Management
A desktop application made with Python/Kivy for managing account related data of college students'
Stars: ✭ 23 (-66.18%)
Mutual labels:  sqlite3

RxDB

RxDB is a high-performance, observable object store built on top of SQLite. RxDB draws inspiration from CoreData and Relay and is intended for database-driven Electron applications. It was originally built for the Nylas N1 mail client.

View the API Reference on GitHub Pages.

An Observable Object Store

  • RxDB queries are Rx.JS Observables. Simply create queries and declaratively bind them to your application's views. Queries internally subscribe to the database, watch for changes, and vend new versions of their result sets as necessary. They've been heavily optimized for performance, and often update without making SQL queries.

  • RxDB databases are event emitters. Want to keep things in sync with your data? Add listeners to refresh application state as objects are saved and removed.

Example: Nylas N1 uses a Flux architecture. Many of the Flux Stores in the application vend state derived from an RxDB database containing the user's mail data. When an object is written to the database, it emits and event, and stores (like the UnreadCountStore) can evaluate whether to update downstream application state.

Basic Usage

Defining a Model:

export default class Note extends Model {
  static attributes = Object.assign(Model.attributes, {
    name: Attributes.String({
      modelKey: 'name',
      jsonKey: 'name',
      queryable: true,
    }),
    content: Attributes.String({
      modelKey: 'content',
      jsonKey: 'content',
    }),
    createdAt: Attributes.DateTime({
      modelKey: 'createdAt',
      jsonKey: 'createdAt',
      queryable: true,
    }),
  });
}

Saving a Model:

const note = new Note({
  name: 'Untitled',
  content: 'Write your note here!',
  createdAt: new Date(),
});
database.inTransaction((t) => {
  return t.persistModel(note);
});

Querying for Models:

database
  .findAll(Note)
  .where({name: 'Untitled'})
  .order(Note.attributes.createdAt.descending())
  .then((notes) => {
  // got some notes!
})

Observing a query:

componentDidMount() {
  const query = database
    .findAll(Note)
    .where({name: 'Untitled'})
    .order(Note.attributes.createdAt.descending())

  this._subscription = query.observe().subscribe((items) => {
    this.setState({items});
  });
}

Features

  • Models:

    • Definition via ES2016 classes extending RxDB.Model
    • Out of the box support for JSON serialization
    • Easy attribute definition and validation
    • Automatic schema generation based on queryable fields
    • Support for splitting object data across tables, keeping SQLite row size small
  • Queries:

    • Results via a Promise API. (`query.then((results) => ...)``)
    • Live results via an Rx.JS Observable API. (query.observable().subscribe((results) => ...))
    • Clean query syntax inspired by ActiveRecord and NSPredicate
    • Support for basic relationships and retrieving of joined objects
    • Full-text search powered by SQLite's FTS5
  • Database:

    • ChangeRecord objects emitted for every modification of data
    • Changes bridged across window processes for multi-window apps
    • Support for opening multiple databases simultaneously
  • High test coverage!

FAQ

How does this fit in to Flux / Redux / etc?

RxDB is not intended to be a replacement for Redux or other application state frameworks, and works great alongside them!

Redux is ideal for storing small bits of state, like the user's current selection. In a typical RxDB application, this application state determines the views that are displayed and the queries that are declaratively bound to those views. Individual components build queries and display the resulting data.

Wait, I can't make UPDATE queries?

RxDB exposes an ActiveRecord-style query syntax, but only for fetching models. RxDB's powerful observable queries, modification hooks, and other features depend on application code being able to see every change to every object.

Queries like UPDATE Note SET read = 1 WHERE ... allow you to make changes with unknown effects, and are explicitly not allowed. (Every live query of a Note would need to be re-run following that change!) Instead of expanding support for arbitrary queries, RxDB focuses on making reading and saving objects blazing fast, so doing a query, modifying a few hundred matches, and saving them back is perfectly fine.

Examples & API Reference

The example "Notes" app may be the best place to get started, but a full API Reference is available on GitHub Pages.

Contributing

Running the Notes Example

npm install
cd ./example
npm install
npm start

Running the Tests

RxDB's tests are written in Jasmine 2 and run in a tiny Electron application for consistency with the target environment. To run the tests, use npm test:

npm install
npm test

You can skip certain tests (temporarily) with xit and xdescribe, or focus on only certain tests with fit and fdescribe.

Running the Linter

npm install
npm run lint
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].