saveNodes method

Future<void> saveNodes(
  1. Node node
)

Saves a node to the graph database.

The node will be persisted to the database and can be retrieved later using loadNode. The node must implement the Node interface and provide a valid Node.toJson method.

Example:

final node = MyNode(id: '1', name: 'Alice');
await box.saveNodes(node);

Implementation

Future<void> saveNodes(Node node) async {
  // C++ code expects a JSON array of nodes, not a single object
  final jsonData = jsonEncode([node.toJson()]);
  final ptr = jsonData.toNativeUtf8().cast<ffi.Char>();
  _bindings.graphdb_save_nodes(_handle, ptr);

  malloc.free(ptr);
}