[][src]Struct dgraph_tonic::Mutation

pub struct Mutation {
    pub set_json: Vec<u8>,
    pub delete_json: Vec<u8>,
    pub set_nquads: Vec<u8>,
    pub del_nquads: Vec<u8>,
    pub set: Vec<NQuad>,
    pub del: Vec<NQuad>,
    pub cond: String,
    pub commit_now: bool,
}

Fields

set_json: Vec<u8>delete_json: Vec<u8>set_nquads: Vec<u8>del_nquads: Vec<u8>set: Vec<NQuad>del: Vec<NQuad>cond: String

This is being used for upserts.

commit_now: bool

This field is a duplicate of the one in Request and placed here for convenience.

Implementations

impl Mutation[src]

pub fn new() -> Self[src]

Create new Dgraph Mutation object.

Mutation represent required modification of data in DB. Mutation provides two main ways to set data: JSON and RDF N-Quad. You can choose whichever way is convenient. JSON way has implemented to helper functions.

pub fn set_set_json<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where
    T: Serialize
[src]

Set set JSON data in Mutation.

Arguments

  • value - ref to struct which can be serialized into JSON

Errors

Return serde_json:Error when value cannot be serialized to JSON format

Examples

use dgraph_tonic::Mutation;
use serde::Serialize;

#[derive(Serialize)]
struct Person {
  uid: String,
  name: String,
}

let p = Person {
  uid:  "_:alice".into(),
  name: "Alice".into(),
};

let mut mu = Mutation::new();
mu.set_set_json(&p).expect("JSON");

pub fn set_delete_json<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where
    T: Serialize
[src]

Set delete JSON data in Mutation.

Arguments

  • value - ref to struct which can be serialized into JSON

Errors

Return serde_json:Error when value cannot be serialized to JSON format

Examples

use dgraph_tonic::Mutation;
use serde::Serialize;

#[derive(Serialize)]
struct Person {
  uid: String,
  name: Option<String>,
}

let p = Person {
  uid:  "_:0x1".into(),
  name: None,
};

let mut mu = Mutation::new();
//remove name predicate
mu.set_delete_json(&p).expect("JSON");

pub fn set_set_nquads<S: Into<String>>(&mut self, nquads: S)[src]

Set set Nquads in Mutation.

Arguments

  • nquads - set nquads

Examples

use dgraph_tonic::Mutation;

let mut mu = Mutation::new();
//remove name predicate
mu.set_set_nquads(r#"uid(user) <email> "correct_email@dgraph.io" ."#);

pub fn set_delete_nquads<S: Into<String>>(&mut self, nquads: S)[src]

Set delete Nquads in Mutation.

Arguments

  • nquads - delete nquads

Examples

use dgraph_tonic::Mutation;

let mut mu = Mutation::new();
//remove name predicate
mu.set_set_nquads(r#"uid(user) <email> * ."#);

pub fn set_cond<S: Into<String>>(&mut self, cond: S)[src]

Set set condition in Mutation.

Arguments

  • cond - set nquads

Examples

use dgraph_tonic::Mutation;

let mut mu = Mutation::new();
//remove name predicate
mu.set_cond("@if(eq(len(user), 1))");

Trait Implementations

impl Clone for Mutation[src]

impl Debug for Mutation[src]

impl Default for Mutation[src]

impl Message for Mutation[src]

impl PartialEq<Mutation> for Mutation[src]

impl StructuralPartialEq for Mutation[src]

Auto Trait Implementations

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> Instrument for T[src]

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

impl<T> IntoRequest<T> for 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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]