Documentation
¶
Overview ¶
Package modifiers provides functionality for modifying nodes and relationships in the graph database. It implements the SET, DELETE, and REMOVE clause execution for Cypher queries.
The modifier supports:
- Setting properties on nodes and relationships
- Adding labels to nodes
- Deleting nodes and relationships
- Removing properties and labels
- Detach delete (delete node with all relationships)
Example:
modifier := modifiers.NewModifier(store)
nodes, err := modifier.ExecuteSet(tx, setStmt, path, params)
if err != nil {
log.Fatal(err)
}
Index ¶
- type Modifier
- func (m *Modifier) ExecuteDelete(t *tx.Transaction, stmt *ast.DeleteStmt, path map[string]interface{}, ...) (affectedNodes, affectedRels int, err error)
- func (m *Modifier) ExecuteRemove(t *tx.Transaction, stmt *ast.RemoveStmt, path map[string]interface{}, ...) (affectedNodes int, err error)
- func (m *Modifier) ExecuteSet(t *tx.Transaction, stmt *ast.SetStmt, path map[string]interface{}, ...) (affectedNodes int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Modifier ¶
type Modifier struct {
// Store is the underlying storage database.
Store *storage.DB
// contains filtered or unexported fields
}
Modifier modifies nodes and relationships in the graph database. It handles the execution of SET, DELETE, and REMOVE statements.
func NewModifier ¶
NewModifier creates a new Modifier instance.
Parameters:
- store: The storage database
- index: The graph index for efficient lookups (shared across components)
- adj: The adjacency list for relationship traversal (shared across components)
Returns a new Modifier instance.
Example:
index := graph.NewIndex(store) adj := graph.NewAdjacencyList(store) modifier := modifiers.NewModifier(store, index, adj)
func (*Modifier) ExecuteDelete ¶
func (m *Modifier) ExecuteDelete(t *tx.Transaction, stmt *ast.DeleteStmt, path map[string]interface{}, params map[string]interface{}) (affectedNodes, affectedRels int, err error)
ExecuteDelete executes a DELETE statement and returns the number of affected elements.
Parameters:
- t: The transaction for atomic operations
- stmt: The DELETE statement AST node
- path: The matched path containing nodes and relationships
- params: Query parameters for parameterized queries
Returns the number of affected nodes, affected relationships, and any error encountered.
Example:
nodes, rels, err := modifier.ExecuteDelete(tx, deleteStmt, path, params)
func (*Modifier) ExecuteRemove ¶
func (m *Modifier) ExecuteRemove(t *tx.Transaction, stmt *ast.RemoveStmt, path map[string]interface{}, params map[string]interface{}) (affectedNodes int, err error)
ExecuteRemove executes a REMOVE statement and returns the number of affected nodes.
Parameters:
- t: The transaction for atomic operations
- stmt: The REMOVE statement AST node
- path: The matched path containing nodes and relationships
- params: Query parameters for parameterized queries
Returns the number of affected nodes and any error encountered.
Example:
affected, err := modifier.ExecuteRemove(tx, removeStmt, path, params)
func (*Modifier) ExecuteSet ¶
func (m *Modifier) ExecuteSet(t *tx.Transaction, stmt *ast.SetStmt, path map[string]interface{}, params map[string]interface{}) (affectedNodes int, err error)
ExecuteSet executes a SET statement and returns the number of affected nodes.
Parameters:
- t: The transaction for atomic operations
- stmt: The SET statement AST node
- path: The matched path containing nodes and relationships
- params: Query parameters for parameterized queries
Returns the number of affected nodes and any error encountered.
Example:
affected, err := modifier.ExecuteSet(tx, setStmt, path, map[string]interface{}{
"name": "Alice",
})