Documentation
¶
Overview ¶
Package creators provides functionality for creating nodes and relationships in the graph database. It implements the CREATE and MERGE clause execution for Cypher queries.
The creator supports:
- Creating nodes with labels and properties
- Creating relationships between nodes
- MERGE operations (create if not exists)
- Parameterized property values
Example:
creator := creators.NewCreator(store)
nodes, rels, err := creator.ExecuteCreate(tx, createStmt, params)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Created %d nodes and %d relationships\n", nodes, rels)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator struct {
// Store is the underlying storage database.
Store *storage.DB
// contains filtered or unexported fields
}
Creator creates nodes and relationships in the graph database. It handles the execution of CREATE and MERGE statements.
func NewCreator ¶
NewCreator creates a new Creator 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 Creator instance.
Example:
index := graph.NewIndex(store) adj := graph.NewAdjacencyList(store) creator := creators.NewCreator(store, index, adj)
func (*Creator) ExecuteCreate ¶ added in v0.2.0
func (c *Creator) ExecuteCreate(t tx.Tx, stmt *ast.CreateStmt, params map[string]interface{}, existingNodes ...map[string]interface{}) (affectedNodes, affectedRels int, err error)
ExecuteCreate executes a CREATE statement and returns the number of affected elements.
Parameters:
- t: The transaction for atomic operations
- stmt: The CREATE statement AST node
- params: Query parameters for parameterized queries
Returns the number of affected nodes, affected relationships, and any error encountered.
Example:
nodes, rels, err := creator.ExecuteCreate(tx, createStmt, map[string]interface{}{
"name": "Alice",
})
func (*Creator) ExecuteMerge ¶ added in v0.2.0
func (c *Creator) ExecuteMerge(t tx.Tx, stmt *ast.MergeStmt, params map[string]interface{}) (affectedNodes, affectedRels int, err error)
ExecuteMerge executes a MERGE statement and returns the number of affected elements. MERGE creates elements only if they don't already exist.
Parameters:
- t: The transaction for atomic operations
- stmt: The MERGE statement AST node
- params: Query parameters for parameterized queries
Returns the number of affected nodes, affected relationships, and any error encountered.
Example:
nodes, rels, err := creator.ExecuteMerge(tx, mergeStmt, params)