creators

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 6 Imported by: 0

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

func NewCreator(store *storage.DB) *Creator

NewCreator creates a new Creator instance.

Parameters:

  • store: The storage database

Returns a new Creator instance.

Example:

creator := creators.NewCreator(store)

func (*Creator) ExecuteCreate added in v0.2.0

func (c *Creator) ExecuteCreate(t tx.Tx, stmt *ast.CreateStmt, params 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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL