Trait indradb::Transaction
[−]
[src]
pub trait Transaction { fn create_vertex(&self, t: &Type) -> Result<Uuid>; fn get_vertices(&self, q: &VertexQuery) -> Result<Vec<Vertex>>; fn delete_vertices(&self, q: &VertexQuery) -> Result<()>; fn get_vertex_count(&self) -> Result<u64>; fn create_edge(&self, key: &EdgeKey) -> Result<bool>; fn get_edges(&self, q: &EdgeQuery) -> Result<Vec<Edge>>; fn delete_edges(&self, q: &EdgeQuery) -> Result<()>; fn get_edge_count(
&self,
id: Uuid,
type_filter: Option<&Type>,
direction: EdgeDirection
) -> Result<u64>; fn get_global_metadata(&self, name: &str) -> Result<Option<JsonValue>>; fn set_global_metadata(&self, name: &str, value: &JsonValue) -> Result<()>; fn delete_global_metadata(&self, name: &str) -> Result<()>; fn get_vertex_metadata(
&self,
q: &VertexQuery,
name: &str
) -> Result<Vec<VertexMetadata>>; fn set_vertex_metadata(
&self,
q: &VertexQuery,
name: &str,
value: &JsonValue
) -> Result<()>; fn delete_vertex_metadata(&self, q: &VertexQuery, name: &str) -> Result<()>; fn get_edge_metadata(
&self,
q: &EdgeQuery,
name: &str
) -> Result<Vec<EdgeMetadata>>; fn set_edge_metadata(
&self,
q: &EdgeQuery,
name: &str,
value: &JsonValue
) -> Result<()>; fn delete_edge_metadata(&self, q: &EdgeQuery, name: &str) -> Result<()>; }
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, t: &Type) -> Result<Uuid>
fn get_vertices(&self, q: &VertexQuery) -> Result<Vec<Vertex>>
fn delete_vertices(&self, q: &VertexQuery) -> Result<()>
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(&self, q: &EdgeQuery) -> Result<Vec<Edge>>
fn delete_edges(&self, q: &EdgeQuery) -> Result<()>
fn get_edge_count(
&self,
id: Uuid,
type_filter: Option<&Type>,
direction: EdgeDirection
) -> Result<u64>
&self,
id: Uuid,
type_filter: Option<&Type>,
direction: EdgeDirection
) -> Result<u64>
Gets the number of edges associated with a vertex.
Arguments
id
- The id of the vertex.type_filter
- Only get the count for a specified edge type.direction
: The direction of edges to get.
fn get_global_metadata(&self, name: &str) -> Result<Option<JsonValue>>
Gets a global metadata value.
Arguments
name
- The metadata name.
Errors
Returns Error::MetadataNotFound
if the metadata does not exist.
fn set_global_metadata(&self, name: &str, value: &JsonValue) -> Result<()>
fn delete_global_metadata(&self, name: &str) -> Result<()>
fn get_vertex_metadata(
&self,
q: &VertexQuery,
name: &str
) -> Result<Vec<VertexMetadata>>
&self,
q: &VertexQuery,
name: &str
) -> Result<Vec<VertexMetadata>>
fn set_vertex_metadata(
&self,
q: &VertexQuery,
name: &str,
value: &JsonValue
) -> Result<()>
&self,
q: &VertexQuery,
name: &str,
value: &JsonValue
) -> Result<()>
Sets a vertex metadata value.
Arguments
q
- The query to run.name
- The metadata name.value
- The metadata value.
fn delete_vertex_metadata(&self, q: &VertexQuery, name: &str) -> Result<()>
fn get_edge_metadata(
&self,
q: &EdgeQuery,
name: &str
) -> Result<Vec<EdgeMetadata>>
&self,
q: &EdgeQuery,
name: &str
) -> Result<Vec<EdgeMetadata>>
fn set_edge_metadata(
&self,
q: &EdgeQuery,
name: &str,
value: &JsonValue
) -> Result<()>
&self,
q: &EdgeQuery,
name: &str,
value: &JsonValue
) -> Result<()>
Sets an edge metadata value.
Arguments
q
- The query to run.name
- The metadata name.value
- The metadata value.
fn delete_edge_metadata(&self, q: &EdgeQuery, name: &str) -> Result<()>
Implementors
impl Transaction for MemoryTransaction