RXDB (short for Reactive Database) is an open-source client-side database that utilizes reactive programming and offline-first principles.
ποΈ Architecture
RXDB follows a modular architecture, which is divided into multiple layers. Each layer has a specific responsibility, making the codebase easy to maintain and extend. The main layers of RXDB are:
π Core Layer: This layer provides the basic functionality of RXDB, such as document CRUD operations and query execution.
𧩠Plugin Layer: Plugins are building blocks that helps to extend the functionality of RXDB. They can be used to provide encryption, sync, and validation features, among others. This layer is responsible for the communication between RXDB and the underlying database system. Currently, RXDB supports multiple adapters, including PouchDB, MongoDB, and SQLite.
ποΈ Data Structures
RXDB uses the JSON data format to store and retrieve data. Each document in RXDB is represented as a JSON object, which can be easily manipulated using JavaScript. Documents can have arbitrary nesting, allowing for complex data structures to be stored in the database.
In addition to the JSON data format, RXDB also supports binary data storage using the Blob data type. This can be useful when working with large files or binary data, such as images or videos.
𧩠Plugins
RXDB's plugin system allows developers to extend the functionality of the database by adding additional features. Some popular plugins include:
Encryption Plugin: This plugin provides transparent encryption for data stored in RXDB. It uses the Web Cryptography API to encrypt and decrypt data on the client-side, ensuring that sensitive data remains secure.
Replication Plugin: This plugin enables data synchronization between multiple instances of RXDB. It uses a variety of synchronization protocols, including PouchDB's Sync Protocol, to keep data consistent across different devices and platforms.
Validation Plugin: This plugin provides data validation and schema enforcement for RXDB. It can be used to ensure that data stored in the database conforms to a specific schema, preventing data corruption and other issues.
Storage
RXDB supports multiple storage options, including:
IndexedDB: This is the default storage backend for RXDB. It is a key-value store that is built into most modern web browsers, making it a good choice for web-based applications.
LocalStorage: This storage backend is also built into most modern web browsers. It provides a simple key-value store, but has a smaller storage capacity than IndexedDB.
Memory: This storage backend stores data in memory, making it useful for testing and debugging purposes.
Custom: RXDB also allows developers to create their own custom storage backends by implementing the RxStorage interface.
Angular + ngrx + rxdb example:
https://github.com/dhrn/rxdb-ngrx-example or https://stackblitz.com/edit/angular-1zvpdc
Top comments (0)