pub trait ToNodeBuilder<T: Display = Self>: Display {
fn with(&self, relation_or_node: &str) -> String { ... }
fn from(&self, node: &str) -> String { ... }
fn as_named_label(&self, label_name: &str) -> String { ... }
fn equals(&self, value: &str) -> String { ... }
fn equals_parameterized(&self) -> String { ... }
fn as_alias(&self, alias: &str) -> String { ... }
fn filter(&self, condition: &str) -> String { ... }
}
Provided Methods
sourcefn with(&self, relation_or_node: &str) -> String
fn with(&self, relation_or_node: &str) -> String
Draws the start of a relation ->node
Example
use surreal_simple_querybuilder::prelude::*;
let s = "user".with("project");
assert_eq!("user->project", s);
sourcefn from(&self, node: &str) -> String
fn from(&self, node: &str) -> String
Draws the end of a relation <-node
Example
use surreal_simple_querybuilder::prelude::*;
let s = "user".from("project");
assert_eq!("user<-project", s);
sourcefn as_named_label(&self, label_name: &str) -> String
fn as_named_label(&self, label_name: &str) -> String
Take the current string and add in front of it the given label name as to
make a string of the following format LabelName:CurrentString
Example
use surreal_simple_querybuilder::prelude::*;
let label = "John".as_named_label("Account");
assert_eq!(label, "Account:John");
sourcefn equals(&self, value: &str) -> String
fn equals(&self, value: &str) -> String
Example
use surreal_simple_querybuilder::prelude::*;
let s = "user".equals("John");
// Note that it doesn't add quotes around strings
assert_eq!("user = John", s);
sourcefn equals_parameterized(&self) -> String
fn equals_parameterized(&self) -> String
Take the current string and add = $current_string
after it
Example
use surreal_simple_querybuilder::prelude::*;
let s = "account".equals_parameterized();
assert_eq!("account = $account", s);
sourcefn as_alias(&self, alias: &str) -> String
fn as_alias(&self, alias: &str) -> String
Take the current string and add as alias
after it
Example
use surreal_simple_querybuilder::prelude::*;
let s = "account->manage->project".as_alias("account_projects");
assert_eq!("account->manage->project AS account_projects", s);
sourcefn filter(&self, condition: &str) -> String
fn filter(&self, condition: &str) -> String
Take the current string, extract the last segment if it is a nested property, then add parenthesis around it and add the supplied condition in them.
Example
use surreal_simple_querybuilder::prelude::*;
let path = "account->manage->project";
let s = path.filter("name = 'a_cool_project'");
assert_eq!("account->manage->(project WHERE name = 'a_cool_project')", s);