TQDB is a small library for creating a query-able database that is encoded with json.
The library is well tested (~96.30% coverage according to cargo-tarpaulin) and simple to use with the help of macros.
We can create a database using any type. ```
use tqdb::Database;
let db1: Database
If the type is serializable, we can even save it as json! ```no_run
use serde::{Serialize, Deserialize};
struct Vec2 { x: i32, y: i32 };
use tqdb::Database;
let db1: Database
db1.savetofile("db1.json")?; db2.savetofile("db2.json")?; db3.savetofile("db3.json")?;
```
We can query a database using macros!
We can search a database... ```
use tqdb::{Database, Query, search, searchmut, remove};
let db = Database::fromiter(1..10);
let found_items = search!(&db match |it: &i32| *it >= 5 && *it <= 7);
...search a database (with mutable access)
let founditemsmut1 = search_mut!(&mut db match |it: &i32| *it >= 5 && *it <= 7);
// or
let founditemsmut2 = search!(&mut db match |it: &i32| *it >= 5 && *it <= 7);
...and remove items easily!
let removed_items = remove!(&mut db match |it: &i32| *it >= 5 && *it <= 7);
If you don't want to use the macros, queries can be composed together like so:
use tqdb::{Database, Query}; let db = Database::from_iter(1..10); // boring, simple query db.search(Query::new(|it: &i32| *it < 5)); // cool AND query db.search( Query::new(|it: &i32| *it < 5) & Query::new(|it: &i32| *it > 2) ); // cool OR query db.search( Query::new(|it: &i32| *it >= 5) | Query::new(|it: &i32| *it <= 2) ); ```