Skip to content

ryankurte/rust-smoldb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smoldb

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.

Features

  • SQL Basics
    • Insert
    • Select
    • Update
    • Delete
  • Extended types (as it stands, everything is strings)
    • Integers
    • Strings
    • Blobs

TODOs

  • Clean up / split macros
  • Make Store impl generic over Storage types
  • Genericise over serde encoder/decoder
  • Fix Index types to use &str and &[u8] in place of String and Vec<u8> respectively

Usage

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).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages