An extremely experimental abstract database interface over SQLite, designed to allow type-safe NoSQL-like* storage of serde
compatible objects with indexing, without needing to write any SQL.
*you can't actually search arbitrary documents, you have to decide on what to index up front. however, you can store arbitrary documents which might be enough for some applications.
This consists of a set of traits in smoldb_traits and a set of proc macros in smoldb_derive, with everything conveniently re-exported in the top-level smoldb
crate.
Check out the example for a working example.
- SQL Basics
- Insert
- Select
- Update
- Delete
- Extended types (as it stands, everything is strings)
- Integers
- Strings
- Blobs
- Clean up / split macros
- Make
Store
impl generic overStorage
types - Genericise over serde encoder/decoder
- Fix Index types to use
&str
and&[u8]
in place ofString
andVec<u8>
respectively
First, define a type that is serializable and derives from Smoldb
.
The #[index]
macro specifies that you would like to be able to search
for objects using this index. Note that any inexable types must implement ToSql
.
#[derive(Clone, Debug, PartialEq, Smoldb, Serialize, Deserialize)]
pub struct User {
#[index]
pub id: isize,
#[index]
pub name: String,
pub email: String,
pub description: String,
}
You can then interact with objects using the Store
traits. Note that some methods require the fully qualified trait syntax to provide type information (usually where you're not passing an object in already).