Struct QueryBuilder

Source
pub struct QueryBuilder {
    pub query_type: Option<QueryKind>,
    pub collection: Option<String>,
    pub comparison: Option<String>,
    pub key: Option<String>,
    pub value: Option<Value>,
}

Fieldsยง

ยงquery_type: Option<QueryKind>ยงcollection: Option<String>ยงcomparison: Option<String>ยงkey: Option<String>ยงvalue: Option<Value>

Implementationsยง

Sourceยง

impl QueryBuilder

Source

pub fn new() -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 29)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn kind(self, typ: QueryKind) -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 31)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn collection(self, collection: &str) -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 30)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn comparison(self, comparison: &str) -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 33)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn string(self, value: &str) -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 34)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn bool(self, value: bool) -> QueryBuilder

Source

pub fn float(self, value: f32) -> QueryBuilder

Source

pub fn int(self, value: i32) -> QueryBuilder

Source

pub fn key(self, key: &str) -> QueryBuilder

Examples found in repository?
examples/store_query.rs (line 32)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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}
Source

pub fn finish(self) -> Query

Examples found in repository?
examples/store_query.rs (line 35)
10fn main() -> Result<(), et::Error> {
11    let mut pot = Et::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ยง

Sourceยง

impl Debug for QueryBuilder

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.