store_query/
store_query.rs1use hotpot_db::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize)]
5struct Person {
6 name: String,
7 age: u8,
8}
9
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 pot.create_collection("address_book")?;
15
16 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 pot.insert::<Person>("address_book", &person)?;
24
25 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 let query = QueryBuilder::new()
30 .collection("address_book")
31 .kind(QueryKind::Object)
32 .key("name")
33 .comparison("=")
34 .string("david holtz")
35 .finish();
36
37 let results = pot.execute(query);
38 println!("{:#?}", results);
39
40 Ok(())
41}