pub struct HotPot {
pub conn: Connection,
pub collections: HashMap<String, Collection>,
}Fieldsยง
ยงconn: Connectionยงcollections: HashMap<String, Collection>Implementationsยง
Sourceยงimpl HotPot
impl HotPot
Sourcepub fn new() -> HotPot
pub fn new() -> HotPot
Examples found in repository?
examples/store_query.rs (line 11)
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 // lets make a new collection
14 pot.create_collection("address_book")?;
15
16 // well make a new item we want to store
17 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 // we insert the object into the collection!
23 pot.insert::<Person>("address_book", &person)?;
24
25 // before we query we can add an index to speed things up
26 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 // finally we can query
29 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}pub fn list_collections(&mut self) -> Result<Vec<String>>
Sourcepub fn create_collection(&mut self, name: &str) -> Result<bool, Error>
pub fn create_collection(&mut self, name: &str) -> Result<bool, Error>
Examples found in repository?
examples/store_query.rs (line 14)
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 // lets make a new collection
14 pot.create_collection("address_book")?;
15
16 // well make a new item we want to store
17 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 // we insert the object into the collection!
23 pot.insert::<Person>("address_book", &person)?;
24
25 // before we query we can add an index to speed things up
26 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 // finally we can query
29 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}Sourcepub fn execute(&self, query: Query) -> Result<Vec<Entry>, Error>
pub fn execute(&self, query: Query) -> Result<Vec<Entry>, Error>
Examples found in repository?
examples/store_query.rs (line 37)
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 // lets make a new collection
14 pot.create_collection("address_book")?;
15
16 // well make a new item we want to store
17 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 // we insert the object into the collection!
23 pot.insert::<Person>("address_book", &person)?;
24
25 // before we query we can add an index to speed things up
26 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 // finally we can query
29 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}pub fn add_object_to_collection( &mut self, cname: &str, val: String, ) -> Result<bool, Error>
Sourcepub fn add_index_to_collection(
&mut self,
collection_name: &str,
key: &str,
index_name: &str,
) -> Result<bool, Error>
pub fn add_index_to_collection( &mut self, collection_name: &str, key: &str, index_name: &str, ) -> Result<bool, Error>
Examples found in repository?
examples/store_query.rs (line 26)
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 // lets make a new collection
14 pot.create_collection("address_book")?;
15
16 // well make a new item we want to store
17 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 // we insert the object into the collection!
23 pot.insert::<Person>("address_book", &person)?;
24
25 // before we query we can add an index to speed things up
26 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 // finally we can query
29 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}Sourcepub fn insert<T: Serialize>(
&mut self,
cname: &str,
svalue: &T,
) -> Result<bool, Error>
pub fn insert<T: Serialize>( &mut self, cname: &str, svalue: &T, ) -> Result<bool, Error>
Examples found in repository?
examples/store_query.rs (line 23)
10fn main() -> Result<(), hotpot_db::Error> {
11 let mut pot = HotPot::new();
12
13 // lets make a new collection
14 pot.create_collection("address_book")?;
15
16 // well make a new item we want to store
17 let person = Person {
18 name: String::from("david holtz"),
19 age: 26,
20 };
21
22 // we insert the object into the collection!
23 pot.insert::<Person>("address_book", &person)?;
24
25 // before we query we can add an index to speed things up
26 pot.add_index_to_collection("address_book", "name", "naming_index")?;
27
28 // finally we can query
29 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}Trait Implementationsยง
Auto Trait Implementationsยง
impl !Freeze for HotPot
impl !RefUnwindSafe for HotPot
impl Send for HotPot
impl !Sync for HotPot
impl Unpin for HotPot
impl UnwindSafe for HotPot
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more