[][src]Struct turingdb_helpers::FieldQuery

pub struct FieldQuery<T> { /* fields omitted */ }

Handles all queries releated to fields

#[derive(Debug, Serialize, Clone)]
pub struct FieldQuery {
   db: String,
   document: String,
   field: String,
   payload: Option<T>,
}

Implementations

impl<T> FieldQuery<T> where
    T: Serialize
[src]

pub async fn new() -> Self[src]

Initialize a new empty field

Usage

use crate::FieldQuery;

FieldQuery::new().await

pub async fn db<'_, '_, '_>(&'_ mut self, name: &'_ str) -> &'_ Self[src]

Add a database name

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo.db("db_name").await;

pub async fn document<'_, '_, '_>(&'_ mut self, name: &'_ str) -> &'_ Self[src]

Add a document name

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await;

pub async fn field<'_, '_, '_>(&'_ mut self, name: &'_ str) -> &'_ Self[src]

Add a field name

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await;

pub async fn payload<'_, '_>(&'_ mut self, value: T) -> &'_ Self[src]

Add a payload of bytes

This takes a generic value and convertes it into bytes using bincode

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await
  .payload("my_data_converted_into_bytes".as_bytes()).await;

pub async fn set<'_>(&'_ self) -> Result<Vec<u8>>[src]

Inserts a key/value to a document in a database

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await
  .payload("my_data_converted_into_bytes".as_bytes()).await
  .set().await

pub async fn get<'_>(&'_ self) -> Result<Vec<u8>>[src]

Gets a value to a document in a database by key

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await
  .get().await;

pub async fn list<'_>(&'_ self) -> Result<Vec<u8>>[src]

List all the keys in a document

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .list().await;

pub async fn remove<'_>(&'_ self) -> Result<Vec<u8>>[src]

Removes a value from a document in a database by key

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await
  .remove().await;

pub async fn modify<'_>(&'_ self) -> Result<Vec<u8>>[src]

Modifies a value in a document in a database by its key

Usage

use crate::FieldQuery;

let mut foo = FieldQuery::new().await;
foo
  .db("db_name").await
  .document("document_name").await
  .field("field_name").await
  .payload("my_data_converted_into_bytes".as_bytes()).await
  .modify().await

Trait Implementations

impl<T: Clone> Clone for FieldQuery<T>[src]

impl<T: Debug> Debug for FieldQuery<T>[src]

impl<T> Serialize for FieldQuery<T> where
    T: Serialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for FieldQuery<T> where
    T: RefUnwindSafe

impl<T> Send for FieldQuery<T> where
    T: Send

impl<T> Sync for FieldQuery<T> where
    T: Sync

impl<T> Unpin for FieldQuery<T> where
    T: Unpin

impl<T> UnwindSafe for FieldQuery<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.