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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?