grafeo library
Dart bindings for the Grafeo graph database.
Provides a native Dart API backed by the grafeo-c shared library via FFI.
Quick Start
import 'package:grafeo/grafeo.dart';
void main() {
final db = GrafeoDB.memory();
db.execute("INSERT (:Person {name: 'Alix', age: 30})");
final result = db.execute(
"MATCH (p:Person) WHERE p.name = 'Alix' RETURN p.name, p.age",
);
print(result); // QueryResult(1 rows, ...)
db.close();
}
Classes
- Edge
- A graph edge with an ID, type, source/target, and properties.
- GrafeoDB
- A Grafeo graph database instance.
- Node
- A graph node with an ID, labels, and properties.
- QueryResult
- The result of a query execution.
- Transaction
- An ACID transaction on a Grafeo database.
- VectorResult
- A single vector search result with a node ID and distance score.
Enums
- GrafeoStatus
- Status codes returned by grafeo-c FFI functions.
- IsolationLevel
- Transaction isolation levels.
Functions
-
classifyError(
int statusCode, String message) → GrafeoException - Map a C status code and error message to a typed Dart exception.
-
encodeParams(
Map< String, dynamic> params) → String - Encode a parameter map as a JSON string for grafeo_execute_with_params.
-
encodeValue(
dynamic value) → String - Encode a single value for the grafeo-c JSON wire format.
-
lastError(
GrafeoBindings bindings) → String - Read the last error message from the grafeo-c thread-local error slot.
-
throwLastError(
GrafeoBindings bindings) → Never - Throw a GrafeoException for a failed FFI call that returned null.
-
throwStatus(
GrafeoBindings bindings, int statusCode) → Never - Throw a GrafeoException for a failed FFI call that returned a status code.
Typedefs
-
GrafeoDatabasePtr
= Pointer<
Void> - Opaque pointer to a Grafeo database.
-
GrafeoResultPtr
= Pointer<
Void> - Opaque pointer to a Grafeo query result.
-
GrafeoTransactionPtr
= Pointer<
Void> - Opaque pointer to a Grafeo transaction.
Exceptions / Errors
- DatabaseException
- A generic database error (status 1, 7, 8, 9, or unknown).
- GrafeoException
- Base exception for all Grafeo errors.
- QueryException
- A query parsing or execution error (status 2).
- SerializationException
- A serialization error (status 6).
- StorageException
- A storage or IO error (status 4, 5).
- TransactionException
- A transaction error such as conflict or invalid state (status 3).