pub trait Transaction<'a> {
Show 28 methods
// Required methods
fn vertex_count(&self) -> u64;
fn all_vertices(&'a self) -> Result<DynIter<'a, Vertex>>;
fn range_vertices(&'a self, offset: Uuid) -> Result<DynIter<'a, Vertex>>;
fn specific_vertices(
&'a self,
ids: Vec<Uuid>,
) -> Result<DynIter<'a, Vertex>>;
fn vertex_ids_with_property(
&'a self,
name: Identifier,
) -> Result<Option<DynIter<'a, Uuid>>>;
fn vertex_ids_with_property_value(
&'a self,
name: Identifier,
value: &Json,
) -> Result<Option<DynIter<'a, Uuid>>>;
fn edge_count(&self) -> u64;
fn all_edges(&'a self) -> Result<DynIter<'a, Edge>>;
fn range_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>;
fn range_reversed_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>;
fn specific_edges(&'a self, edges: Vec<Edge>) -> Result<DynIter<'a, Edge>>;
fn edges_with_property(
&'a self,
name: Identifier,
) -> Result<Option<DynIter<'a, Edge>>>;
fn edges_with_property_value(
&'a self,
name: Identifier,
value: &Json,
) -> Result<Option<DynIter<'a, Edge>>>;
fn vertex_property(
&self,
vertex: &Vertex,
name: Identifier,
) -> Result<Option<Json>>;
fn all_vertex_properties_for_vertex(
&'a self,
vertex: &Vertex,
) -> Result<DynIter<'a, (Identifier, Json)>>;
fn edge_property(
&self,
edge: &Edge,
name: Identifier,
) -> Result<Option<Json>>;
fn all_edge_properties_for_edge(
&'a self,
edge: &Edge,
) -> Result<DynIter<'a, (Identifier, Json)>>;
fn delete_vertices(&mut self, vertices: Vec<Vertex>) -> Result<()>;
fn delete_edges(&mut self, edges: Vec<Edge>) -> Result<()>;
fn delete_vertex_properties(
&mut self,
props: Vec<(Uuid, Identifier)>,
) -> Result<()>;
fn delete_edge_properties(
&mut self,
props: Vec<(Edge, Identifier)>,
) -> Result<()>;
fn create_vertex(&mut self, vertex: &Vertex) -> Result<bool>;
fn create_edge(&mut self, edge: &Edge) -> Result<bool>;
fn index_property(&mut self, name: Identifier) -> Result<()>;
fn set_vertex_properties(
&mut self,
vertices: Vec<Uuid>,
name: Identifier,
value: &Json,
) -> Result<()>;
fn set_edge_properties(
&mut self,
edges: Vec<Edge>,
name: Identifier,
value: &Json,
) -> Result<()>;
// Provided methods
fn sync(&self) -> Result<()> { ... }
fn bulk_insert(&mut self, items: Vec<BulkInsertItem>) -> Result<()> { ... }
}
Expand description
Specifies a datastore transaction, which contains nearly all of the datastore implementation-specific logic.
Note that this trait and its members purposefully do not employ any generic arguments. While that would improve ergonomics, it would remove object safety, which we need for plugins.
§Errors
Nearly all methods may return an error if something unexpected happens - e.g. if there was a problem connecting to the underlying database.
Required Methods§
Sourcefn vertex_count(&self) -> u64
fn vertex_count(&self) -> u64
Gets the number of vertices.
Sourcefn all_vertices(&'a self) -> Result<DynIter<'a, Vertex>>
fn all_vertices(&'a self) -> Result<DynIter<'a, Vertex>>
Returns all vertices.
Sourcefn range_vertices(&'a self, offset: Uuid) -> Result<DynIter<'a, Vertex>>
fn range_vertices(&'a self, offset: Uuid) -> Result<DynIter<'a, Vertex>>
Returns all vertices with id >= offset
.
§Arguments
offset
- Only fetch vertices with an offset greater than or equal to this value.
Sourcefn specific_vertices(&'a self, ids: Vec<Uuid>) -> Result<DynIter<'a, Vertex>>
fn specific_vertices(&'a self, ids: Vec<Uuid>) -> Result<DynIter<'a, Vertex>>
Gets a specific set of vertices with the given IDs.
Sourcefn vertex_ids_with_property(
&'a self,
name: Identifier,
) -> Result<Option<DynIter<'a, Uuid>>>
fn vertex_ids_with_property( &'a self, name: Identifier, ) -> Result<Option<DynIter<'a, Uuid>>>
Sourcefn vertex_ids_with_property_value(
&'a self,
name: Identifier,
value: &Json,
) -> Result<Option<DynIter<'a, Uuid>>>
fn vertex_ids_with_property_value( &'a self, name: Identifier, value: &Json, ) -> Result<Option<DynIter<'a, Uuid>>>
Get all vertices with a given property value.
§Arguments
name
- The property name.value
- The property value.
Sourcefn edge_count(&self) -> u64
fn edge_count(&self) -> u64
Gets the number of edges.
Sourcefn range_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>
fn range_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>
Returns all edges with that are greater than or equal to offset
.
§Arguments
offset
- Only fetch edges greater than or equal to this value.
Sourcefn range_reversed_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>
fn range_reversed_edges(&'a self, offset: Edge) -> Result<DynIter<'a, Edge>>
Returns all reversed edges (where the outbound and inbound IDs are
reversed from their actual values) that are greater than or equal
to offset
.
§Arguments
offset
- Only fetch edges greater than or equal to this value.
Sourcefn edges_with_property(
&'a self,
name: Identifier,
) -> Result<Option<DynIter<'a, Edge>>>
fn edges_with_property( &'a self, name: Identifier, ) -> Result<Option<DynIter<'a, Edge>>>
Sourcefn edges_with_property_value(
&'a self,
name: Identifier,
value: &Json,
) -> Result<Option<DynIter<'a, Edge>>>
fn edges_with_property_value( &'a self, name: Identifier, value: &Json, ) -> Result<Option<DynIter<'a, Edge>>>
Get all edges with a given property value.
§Arguments
name
- The property name.value
- The property value.
Sourcefn vertex_property(
&self,
vertex: &Vertex,
name: Identifier,
) -> Result<Option<Json>>
fn vertex_property( &self, vertex: &Vertex, name: Identifier, ) -> Result<Option<Json>>
Gets the value of a vertex property if it exists, or None
otherwise.
§Arguments
vertex
- The vertex.name
- The property name.
Sourcefn all_vertex_properties_for_vertex(
&'a self,
vertex: &Vertex,
) -> Result<DynIter<'a, (Identifier, Json)>>
fn all_vertex_properties_for_vertex( &'a self, vertex: &Vertex, ) -> Result<DynIter<'a, (Identifier, Json)>>
Sourcefn edge_property(&self, edge: &Edge, name: Identifier) -> Result<Option<Json>>
fn edge_property(&self, edge: &Edge, name: Identifier) -> Result<Option<Json>>
Gets the value of an edge property if it exists, or None
otherwise.
§Arguments
edge
- The edge.name
- The property name.
Sourcefn all_edge_properties_for_edge(
&'a self,
edge: &Edge,
) -> Result<DynIter<'a, (Identifier, Json)>>
fn all_edge_properties_for_edge( &'a self, edge: &Edge, ) -> Result<DynIter<'a, (Identifier, Json)>>
Sourcefn delete_vertex_properties(
&mut self,
props: Vec<(Uuid, Identifier)>,
) -> Result<()>
fn delete_vertex_properties( &mut self, props: Vec<(Uuid, Identifier)>, ) -> Result<()>
Sourcefn delete_edge_properties(
&mut self,
props: Vec<(Edge, Identifier)>,
) -> Result<()>
fn delete_edge_properties( &mut self, props: Vec<(Edge, Identifier)>, ) -> Result<()>
Sourcefn create_vertex(&mut self, vertex: &Vertex) -> Result<bool>
fn create_vertex(&mut 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.
Sourcefn create_edge(&mut self, edge: &Edge) -> Result<bool>
fn create_edge(&mut self, edge: &Edge) -> Result<bool>
Creates a new edge. Returns whether the edge was successfully created - if this is false, it’s because one of the specified vertices is missing.
§Arguments
edge
: The edge to create.
Sourcefn index_property(&mut self, name: Identifier) -> Result<()>
fn index_property(&mut self, name: Identifier) -> Result<()>
Enables indexing on a specified property. When indexing is enabled on a property, it’s possible to query on its presence and values.
§Arguments
name
: The name of the property to index.
Sourcefn set_vertex_properties(
&mut self,
vertices: Vec<Uuid>,
name: Identifier,
value: &Json,
) -> Result<()>
fn set_vertex_properties( &mut self, vertices: Vec<Uuid>, name: Identifier, value: &Json, ) -> Result<()>
Sets vertex properties.
§Arguments
vertices
: The vertices to set the properties on.name
: The property name.value
: The property value.
Sourcefn set_edge_properties(
&mut self,
edges: Vec<Edge>,
name: Identifier,
value: &Json,
) -> Result<()>
fn set_edge_properties( &mut self, edges: Vec<Edge>, name: Identifier, value: &Json, ) -> Result<()>
Sets edge properties.
§Arguments
edges
: The edges to set the properties on.name
: The property name.value
: The property value.
Provided Methods§
Sourcefn sync(&self) -> Result<()>
fn sync(&self) -> Result<()>
Syncs persisted content. By default, this errors out, but this can be overridden in datastores that support syncing.
Sourcefn bulk_insert(&mut self, items: Vec<BulkInsertItem>) -> Result<()>
fn bulk_insert(&mut self, items: Vec<BulkInsertItem>) -> Result<()>
Bulk inserts many vertices, edges, and/or properties. By default, this makes the underlying calls to insert the values, but can be overridden to offer a more efficient implementation.
§Arguments
items
: The items to insert.