The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Neo4j::Driver::SummaryCounters - Statement statistics


version 0.49


 use Neo4j::Driver;
 $driver = Neo4j::Driver->new->basic_auth(...);
 $transaction = $driver->session->begin_transaction;
 $transaction->{return_stats} = 1;
 $query = 'MATCH (n:Novel {name:"1984"}) SET n.writer = "Orwell"';
 $result = $transaction->run($query);
 $counters = $result->summary->counters;
 $database_modified = $counters->contains_updates;
 die "That didn't work out." unless $database_modified;


Contains counters for various operations that a statement triggered.

To obtain summary counters, call "counters" in Neo4j::Driver::ResultSummary.


Neo4j::Driver::SummaryCounters implements the following read-only attributes.

 my $constraints_added     = $counters->constraints_added;
 my $constraints_removed   = $counters->constraints_removed;
 my $contains_updates      = $counters->contains_updates;
 my $indexes_added         = $counters->indexes_added;
 my $indexes_removed       = $counters->indexes_removed;
 my $labels_added          = $counters->labels_added;
 my $labels_removed        = $counters->labels_removed;
 my $nodes_created         = $counters->nodes_created;
 my $nodes_deleted         = $counters->nodes_deleted;
 my $properties_set        = $counters->properties_set;
 my $relationships_created = $counters->relationships_created;
 my $relationships_deleted = $counters->relationships_deleted;


These counters may not be useful for verifying that writing to the database was successful. For one thing, explicit transactions may later be rolled back, rendering these statistics outdated. For another, certain error conditions produce misleading statistics: It was observed that deleting a node that has relationships fails in a Cypher shell with an obscure error message, while it succeeds when executed over HTTP with this driver. However, the HTTP response then reports that the node was deleted, but that the relationship wasn't, which is obviously inconsistent. Not quite sure what is going on there. To verify that modifying the database was successful, it would therefore probably make more sense to run a MATCH query, tedious or not.



Arne Johannessen (AJNN)


This software is Copyright (c) 2016-2024 by Arne Johannessen.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 or (at your option) the same terms as the Perl 5 programming language system itself.