Documentation
¶
Overview ¶
Package api provides the public database API for gograph, a graph database engine. It offers a high-level interface for executing Cypher queries and managing graph data including nodes, relationships, and their properties.
Package api provides the public database API for gograph, a graph database engine.
Package api provides the public database API for gograph, a graph database engine.
Index ¶
- Variables
- type DB
- func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) Exec(ctx context.Context, cypherQuery string, args ...interface{}) (Result, error)
- func (db *DB) IsClosed() bool
- func (db *DB) Query(ctx context.Context, cypherQuery string, args ...interface{}) (*Rows, error)
- type DBOption
- type Result
- type Rows
- type Tx
- type TxOptions
Constants ¶
This section is empty.
Variables ¶
var ErrDBClosed = errors.New("database is closed")
ErrDBClosed is returned when attempting to perform operations on a closed database.
var ErrNoMoreRows = errors.New("no more rows")
ErrNoMoreRows is returned by Scan when there are no more rows to read.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a graph database instance. It provides methods for executing Cypher queries and managing transactions. A DB instance is safe for concurrent use by multiple goroutines.
func Open ¶
Open opens a database at the specified path and returns a DB instance. The path is used as the storage location for the underlying Pebble database. Optional DBOption functions can be provided to configure the database.
func (*DB) BeginTx ¶
BeginTx starts a new transaction with the specified options. If opts is nil, a read-write transaction is started. A transaction allows grouping multiple operations into a single atomic unit.
func (*DB) Close ¶
Close closes the database and releases all associated resources. It returns an error if the database is already closed.
func (*DB) Exec ¶
Exec executes a Cypher query that modifies data (CREATE, SET, DELETE, REMOVE) and returns a Result containing the count of affected nodes and relationships. The query can include optional positional parameters passed as arguments.
type DBOption ¶
type DBOption func(*DB)
DBOption configures optional parameters for database operations.
func WithObservability ¶
func WithObservability(o *cypher.Observability) DBOption
WithObservability enables observability features for the database executor, allowing tracing and metrics collection during query execution.
type Result ¶
Result contains the count of affected graph elements after executing a data-modifying Cypher query (CREATE, SET, DELETE, REMOVE).
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows represents a result set iterator from a Cypher query. It provides methods to iterate over the rows and scan column values into Go variables.
func (*Rows) Close ¶
Close releases the Rows resources. It is idempotent and safe to call multiple times.
func (*Rows) Next ¶
Next advances the iterator to the next row. It returns true if there is a next row, or false if there are no more rows.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a database transaction. It provides methods for executing Cypher queries within a transaction. A transaction is safe for concurrent use by multiple goroutines, though serial execution is recommended.
func (*Tx) Commit ¶
Commit commits the transaction, making all changes permanent. Returns an error if the transaction is already closed or if the commit fails.
func (*Tx) Exec ¶
Exec executes a Cypher query within the transaction and returns a Result containing the count of affected nodes and relationships. The query can include optional positional parameters passed as arguments.