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).
- Fast, see
sqlite
vsredb
vsnative_db
benchmarks. - Transparent serialization/deserialization using native_model. You can use any serialization library you want (
bincode
,postcard
, your own etc.). - Ensure query type safety to prevent unexpected results caused by selecting with an incorrect type.
- 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.8.1"
= "0.4.20"
NOTE: native_db
requires native_model
to work.
Status
Active development. The API is not stable yet and may change in the future.
How to use?
- Documentation API
- Quick Start
- Full example with Tauri: native_db_tauri_vanilla
Projects using Native DB
If you want to propose your project or company that uses Native DB, please open a PR.
Example
use ;
use *;
use ;
use Lazy;
// Define the models
// The lifetime of the models needs to be longer or equal to the lifetime of the database.
// In many cases, it is simpler to use a static variable but it is not mandatory.
static MODELS: = new;