Struct holmes::pg::PgDB
[−]
[src]
pub struct PgDB { /* fields omitted */ }
Object representing a postgres-backed fact database instance
Methods
impl PgDB
[src]
fn new(uri: &str) -> Result<PgDB>
Create a new PgDB object by passing in a Postgres connection string
fn destroy(uri: &str) -> Result<()>
Kick everyone off the database and destroy the data at the provided URI
Trait Implementations
impl FactDB for PgDB
[src]
type Error = Error
FactDB implementation provided error type
fn new_rule_cache(&self, preds: Vec<String>) -> Result<CacheId>
Creates a cache table for a new rule, returning a handle
fn cache_hit(&self, cache: CacheId, facts: Vec<FactId>) -> Result<()>
Update
fn insert_fact(&self, fact: &Fact) -> Result<bool>
Adds a new fact to the database, returning false if the fact was already present in the database, and true if it was inserted.
fn add_type(&self, type_: Type) -> Result<()>
Registers a new type with the database. This is unstable, and will likely need to be moved to the initialization of the database object in order to allow reconnecting to an existing database.
fn get_type(&self, type_str: &str) -> Option<Type>
Looks for a named type in the database's registry. This function is primarily useful for the DSL shorthand for constructing queries, since it allows you to use names of types when declaring functions rather than type objects.
fn get_predicate(&self, pred_name: &str) -> Option<Predicate>
Fetches a predicate by name
fn new_predicate(&self, pred: &Predicate) -> Result<()>
Persists a predicate by name The name must consist only of lower case ASCII and _, anything else will be rejected. This restriction is because the predicate name is currently used to construct the table name.
In the future, this restriction could be lifted by generating table names rather than using the names of predicates, but this helps a lot with debugging for now.
fn search_facts(
&self,
query: &Vec<Clause>,
cache: Option<CacheId>
) -> Result<Vec<(Vec<FactId>, Vec<Value>)>>
&self,
query: &Vec<Clause>,
cache: Option<CacheId>
) -> Result<Vec<(Vec<FactId>, Vec<Value>)>>
Attempt to match the right hand side of a datalog rule against the database, returning a list of solution assignments to the bound variables.