saveEdges method

Future<void> saveEdges(
  1. Edge edge
)

Saves an edge to the graph database.

The edge represents a connection between two nodes and will be persisted to the database. Edges can be retrieved using loadEdges by querying from a specific node. The edge must implement the Edge interface and provide a valid Edge.toJson method.

Example:

final edge = MyEdge(from: 'node1', to: 'node2', weight: 1.0);
await box.saveEdges(edge);

Implementation

Future<void> saveEdges(Edge edge) async {
  // C++ code expects a JSON array of edges, not a single object
  final jsonData = jsonEncode([edge.toJson()]);
  final ptr = jsonData.toNativeUtf8().cast<ffi.Char>();
  _bindings.graphdb_save_edges(_handle, ptr);
  malloc.free(ptr);
}