[][src]Trait indradb::Transaction

pub trait Transaction {
    fn create_vertex(&self, vertex: &Vertex) -> Result<bool>;
fn get_vertices<Q: Into<VertexQuery>>(&self, q: Q) -> Result<Vec<Vertex>>;
fn delete_vertices<Q: Into<VertexQuery>>(&self, q: Q) -> Result<()>;
fn get_vertex_count(&self) -> Result<u64>;
fn create_edge(&self, key: &EdgeKey) -> Result<bool>;
fn get_edges<Q: Into<EdgeQuery>>(&self, q: Q) -> Result<Vec<Edge>>;
fn delete_edges<Q: Into<EdgeQuery>>(&self, q: Q) -> Result<()>;
fn get_edge_count(
        &self,
        id: Uuid,
        t: Option<&Type>,
        direction: EdgeDirection
    ) -> Result<u64>;
fn get_vertex_properties(
        &self,
        q: VertexPropertyQuery
    ) -> Result<Vec<VertexProperty>>;
fn get_all_vertex_properties<Q: Into<VertexQuery>>(
        &self,
        q: Q
    ) -> Result<Vec<VertexProperties>>;
fn set_vertex_properties(
        &self,
        q: VertexPropertyQuery,
        value: &JsonValue
    ) -> Result<()>;
fn delete_vertex_properties(&self, q: VertexPropertyQuery) -> Result<()>;
fn get_edge_properties(
        &self,
        q: EdgePropertyQuery
    ) -> Result<Vec<EdgeProperty>>;
fn get_all_edge_properties<Q: Into<EdgeQuery>>(
        &self,
        q: Q
    ) -> Result<Vec<EdgeProperties>>;
fn set_edge_properties(
        &self,
        q: EdgePropertyQuery,
        value: &JsonValue
    ) -> Result<()>;
fn delete_edge_properties(&self, q: EdgePropertyQuery) -> Result<()>; fn create_vertex_from_type(&self, t: Type) -> Result<Uuid> { ... } }

Specifies a transaction implementation, which are returned by datastores. All datastore manipulations are done through transactions. Despite the name, different datastore implementations carry different guarantees. Depending on the implementation, it may not be possible to rollback the changes on error. See the documentation of individual implementations for details. Transactions are automatically committed on drop. Transactions should be designed to not fail on commit; i.e. errors should occur when a method is actually called instead.

Required methods

fn create_vertex(&self, vertex: &Vertex) -> Result<bool>

Creates a new vertex. Returns whether the vertex was successfully created - if this is false, it's because a vertex with the same UUID already exists.

Arguments

  • vertex: The vertex to create.

fn get_vertices<Q: Into<VertexQuery>>(&self, q: Q) -> Result<Vec<Vertex>>

Gets a range of vertices specified by a query.

Arguments

  • q - The query to run.

fn delete_vertices<Q: Into<VertexQuery>>(&self, q: Q) -> Result<()>

Deletes existing vertices specified by a query.

Arguments

  • q - The query to run.

fn get_vertex_count(&self) -> Result<u64>

Gets the number of vertices in the datastore..

fn create_edge(&self, key: &EdgeKey) -> Result<bool>

Creates a new edge. If the edge already exists, this will update it with a new update datetime. Returns whether the edge was successfully created - if this is false, it's because one of the specified vertices is missing.

Arguments

  • key: The edge to create.

fn get_edges<Q: Into<EdgeQuery>>(&self, q: Q) -> Result<Vec<Edge>>

Gets a range of edges specified by a query.

Arguments

  • q - The query to run.

fn delete_edges<Q: Into<EdgeQuery>>(&self, q: Q) -> Result<()>

Deletes a set of edges specified by a query.

Arguments

  • q - The query to run.

fn get_edge_count(
    &self,
    id: Uuid,
    t: Option<&Type>,
    direction: EdgeDirection
) -> Result<u64>

Gets the number of edges associated with a vertex.

Arguments

  • id - The id of the vertex.
  • t - Only get the count for a specified edge type.
  • direction: The direction of edges to get.

fn get_vertex_properties(
    &self,
    q: VertexPropertyQuery
) -> Result<Vec<VertexProperty>>

Gets vertex properties.

Arguments

  • q - The query to run.
  • name - The property name.

fn get_all_vertex_properties<Q: Into<VertexQuery>>(
    &self,
    q: Q
) -> Result<Vec<VertexProperties>>

Gets all vertex properties.

Arguments

  • q - The query to run.

fn set_vertex_properties(
    &self,
    q: VertexPropertyQuery,
    value: &JsonValue
) -> Result<()>

Sets a vertex properties.

Arguments

  • q - The query to run.
  • name - The property name.
  • value - The property value.

fn delete_vertex_properties(&self, q: VertexPropertyQuery) -> Result<()>

Deletes vertex properties.

Arguments

  • q - The query to run.
  • name - The property name.

fn get_edge_properties(&self, q: EdgePropertyQuery) -> Result<Vec<EdgeProperty>>

Gets edge properties.

Arguments

  • q - The query to run.
  • name - The property name.

fn get_all_edge_properties<Q: Into<EdgeQuery>>(
    &self,
    q: Q
) -> Result<Vec<EdgeProperties>>

Gets all edge properties.

Arguments

  • q - The query to run.

fn set_edge_properties(
    &self,
    q: EdgePropertyQuery,
    value: &JsonValue
) -> Result<()>

Sets edge properties.

Arguments

  • q - The query to run.
  • name - The property name.
  • value - The property value.

fn delete_edge_properties(&self, q: EdgePropertyQuery) -> Result<()>

Deletes edge properties.

Arguments

  • q - The query to run.
  • name - The property name.
Loading content...

Provided methods

fn create_vertex_from_type(&self, t: Type) -> Result<Uuid>

Creates a new vertex with just a type specification. As opposed to create_vertex, this is used when you do not want to manually specify the vertex's UUID. Returns the new vertex's UUID.

Arguments

  • t: The type of the vertex to create.
Loading content...

Implementors

impl Transaction for MemoryTransaction[src]

Loading content...