RxDB

适用于 JavaScript 应用程序的快速、本地优先、反应型数据库。「A fast, local first, reactive Database for JavaScript Applications」

Github星跟踪图

Announcement
             Version 16.0.0 is now released, read the CHANGELOG               

Use the quickstart, read the documentation or explore the example projects.

RxDB is a proven technology used by thousands of developers worldwide. With its flexibility, RxDB is used in a diverse range of apps and services.

realtime.gif

RxDB provides an easy to implement, battle-tested replication protocol for realtime sync with your existing infrastructure.
You do not have to use a specific cloud or backend database. The protocol works by implementing three simple HTTP endpoints.
There are also production-ready plugins to easily replicate with GraphQL, CouchDB, Websocket, WebRTC (P2P),Supabase, Firestore or NATS.

RxDB is based on a storage interface that enables you to swap out the underlying storage engine. This increases code reuse because the same database code can be used in different JavaScript environments by just switching out the storage settings.

You can use RxDB on top of IndexedDB, OPFS, LokiJS, Dexie.js, in-memory, SQLite, in a WebWorker thread and even on top of FoundationDB and DenoKV.

No matter what kind of runtime you have, as long as it runs JavaScript, it can run RxDB:

Since its beginning in 2018, RxDB has gained a huge set of features and plugins which makes it a flexible full solution regardless of which type of application you are building. Every feature that you need now or might need in the future is already there.

Install

npm install rxdb rxjs --save

Store data

import { 
  createRxDatabase
} from 'rxdb/plugins/core';

/**
 * For browsers, we use the dexie.js based storage
 * which stores data in IndexedDB in the browser.
 * In other JavaScript runtimes, we can use different storages:
 * @link https://rxdb.info/rx-storage.html
 */
import { getRxStorageDexie } from 'rxdb/plugins/storage-dexie';

// create a database
const db = await createRxDatabase({
    name: 'heroesdb', // the name of the database
    storage: getRxStorageDexie()
});

// add collections
await db.addCollections({
  heroes: {
    schema: mySchema
  }
});

// insert a document
await db.heroes.insert({
  name: 'Bob',
  healthpoints: 100
});

Query data once

const aliveHeroes = await db.heroes.find({
  selector: {
    healthpoints: {
      $gt: 0
    }
  }
}).exec(); // the exec() returns the result once

Observe a Query

await db.heroes.find({
  selector: {
    healthpoints: {
      $gt: 0
    }
  }
})
.$ // the $ returns an observable that emits each time the result set of the query changes
.subscribe(aliveHeroes => console.dir(aliveHeroes));

Get started now by reading the docs or exploring the example-projects.

More content

Angular Database, Frontend Database, localStorage, React Database, Browser Database, React Native Database, PWA Database, In-memory NoSQL database, JSON database, Angular IndexedDB, React IndexedDB, Optimistic UI, local database, React Native Encryption

主要指标

概览
名称与所有者pubkey/rxdb
主编程语言TypeScript
编程语言JavaScript (语言数: 6)
平台
许可证Apache License 2.0
所有者活动
创建于2016-12-02 19:34:42
推送于2025-04-19 01:50:03
最后一次提交2025-04-19 01:49:09
发布数496
最新版本名称16.11.0 (发布于 )
第一版名称6.0.0 (发布于 )
用户参与
星数22.3k
关注者数206
派生数1.1k
提交数12.7k
已启用问题?
问题数787
打开的问题数4
拉请求数5538
打开的拉请求数6
关闭的拉请求数661
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?