Native DB
Here's a drop-in, fast, embedded database for multi-platform apps (server, desktop, mobile). Sync Rust types effortlessly. Enjoy! 😌🍃.
Features
- Simple API 🦀.
- Support for multiple indexes (primary, secondary, unique, non-unique, optional).
- Minimal boilerplate see benchmarks.
- Transparent serialization/deserialization using native_model.
- Automatic model migration 🌟.
- Thread-safe and fully ACID-compliant transactions provided by redb.
- Real-time subscription with filters for
insert
,update
anddelete
operations. - Compatible with all Rust types (
enum
,struct
,tuple
etc.). - Hot snapshots.
Installation
Add this to your Cargo.toml
:
[]
= "0.5.3"
= "0.4.6"
NOTE: native_db
requires native_model
to work.
Status
Active development. The API is not stable yet and may change in the future.
Usage
- With Tauri: native_db_tauri_vanilla
Usual API
- DatabaseBuilder
- define a model.
- create / open a database.
- create_in_memory an in-memory database.
- Database
- snapshot the database.
- rw_transaction open a read-write transaction.
- r_transaction open a read-only transaction.
- get
- scan
- primary
- all items.
- start_with items with a primary key starting with a given value.
- range items with a primary key in a given range.
- secondary
- all items with a given secondary key.
- start_with items with a secondary key starting with a given value.
- range items with a secondary key in a given range.
- primary
- len
- watch real-time subscriptions via std channel based or tokio channel based depending on the feature
tokio
.- get
- scan
- primary
- all items.
- start_with items with a primary key starting with a given value.
- range items with a primary key in a given range.
- secondary
- all items with a given secondary key.
- start_with items with a secondary key starting with a given value.
- range items with a secondary key in a given range.
- primary
Example
use ;
use *;
use ;