Skip to content

Commit e71ba54

Browse files
committed
Rename: updateStatistics->counters.
In order to be consistent between driversm `updateStatistics` is now called counters in line with the other drivers. Using `updateStatistics` will still work but is deprecated and will be removed in future versions.
1 parent b4da125 commit e71ba54

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/v1/result-summary.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ class ResultSummary {
3333
constructor(statement, parameters, metadata) {
3434
this.statement = {text: statement, parameters};
3535
this.statementType = metadata.type;
36-
this.updateStatistics = new StatementStatistics(metadata.stats || {});
36+
let counters = new StatementStatistics(metadata.stats || {});
37+
this.counters = counters;
38+
//for backwards compatibility, remove in future version
39+
this.updateStatistics = counters;
3740
this.plan = metadata.plan || metadata.profile ? new Plan(metadata.plan || metadata.profile) : false;
3841
this.profile = metadata.profile ? new ProfiledPlan(metadata.profile) : false;
3942
this.notifications = this._buildNotifications(metadata.notifications);
4043
}
41-
4244
_buildNotifications(notifications) {
4345
if(!notifications) {
4446
return [];

test/v1/examples.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('examples', function() {
8888
var s = driver.session();
8989
s.run( "CREATE (p:Person { name: {name} })", {name: "The One"} )
9090
.then( function(result) {
91-
var theOnesCreated = result.summary.updateStatistics.nodesCreated();
91+
var theOnesCreated = result.summary.counters.nodesCreated();
9292
console.log(theOnesCreated);
9393
s.close();
9494
driver.close();
@@ -106,7 +106,7 @@ describe('examples', function() {
106106
.run( "CREATE (person:Person {name: {name}})", {name: "Arthur"} )
107107
// end::statement[]
108108
.then( function(result) {
109-
var theOnesCreated = result.summary.updateStatistics.nodesCreated();
109+
var theOnesCreated = result.summary.counters.nodesCreated();
110110
console.log("There were " + theOnesCreated + " the ones created.")
111111
})
112112
.then(function() {
@@ -122,7 +122,7 @@ describe('examples', function() {
122122
.run( "CREATE (p:Person { name: 'Arthur' })" )
123123
// end::statement-without-parameters[]
124124
.then( function(result) {
125-
var theOnesCreated = result.summary.updateStatistics.nodesCreated();
125+
var theOnesCreated = result.summary.counters.nodesCreated();
126126
console.log("There were " + theOnesCreated + " the ones created.");
127127
});
128128

test/v1/session.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ describe('session', function () {
151151
var sum = result.summary;
152152
expect(sum.statement.text).toBe(statement);
153153
expect(sum.statement.parameters).toBe(params);
154-
expect(sum.updateStatistics.containsUpdates()).toBe(true);
155-
expect(sum.updateStatistics.nodesCreated()).toBe(1);
154+
expect(sum.counters.containsUpdates()).toBe(true);
155+
expect(sum.counters.nodesCreated()).toBe(1);
156156
expect(sum.statementType).toBe(StatementType.READ_WRITE);
157157
done();
158158
});

test/v1/tck/steps/resultapisteps.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ module.exports = function () {
5656
});
5757

5858
this.Then(/^requesting `Counters` from `Result Summary` should give$/, function (table) {
59-
var updateStatistics = this.summary.updateStatistics
59+
var counters = this.summary.counters;
6060
for ( var i = 0 ; i < table.hashes().length; i++) {
6161
var statistic = table.hashes()[i].counter;
6262
var expected = util.literalValueToTestValueNormalIntegers(table.hashes()[i].result);
63-
var given = getStatistic(statistic, updateStatistics)
63+
var given = getStatistic(statistic, counters)
6464
if (!util.compareValues(given, expected)) {
6565
throw Error("Statistics for: " + statistic + " does not match. Expected: '" + expected + "' Given: '" + given + "'");
6666
}
@@ -195,42 +195,42 @@ this.Then(/^the `Result Summary` `Notifications` has one notification with$/, fu
195195
throw Error("No statement type mapping of: " + type)
196196
}
197197

198-
function getStatistic(statementString, updateStatistics) {
198+
function getStatistic(statementString, counters) {
199199
if (statementString == 'nodes created') {
200-
return updateStatistics.nodesCreated();
200+
return counters.nodesCreated();
201201
}
202202
if (statementString == 'nodes deleted') {
203-
return updateStatistics.nodesDeleted();
203+
return counters.nodesDeleted();
204204
}
205205
if (statementString == 'relationships created') {
206-
return updateStatistics.relationshipsCreated();
206+
return counters.relationshipsCreated();
207207
}
208208
if (statementString == 'relationships deleted') {
209-
return updateStatistics.relationshipsDeleted();
209+
return counters.relationshipsDeleted();
210210
}
211211
if (statementString == 'properties set') {
212-
return updateStatistics.propertiesSet();
212+
return counters.propertiesSet();
213213
}
214214
if (statementString == 'labels added') {
215-
return updateStatistics.labelsAdded();
215+
return counters.labelsAdded();
216216
}
217217
if (statementString == 'labels removed') {
218-
return updateStatistics.labelsRemoved();
218+
return counters.labelsRemoved();
219219
}
220220
if (statementString == 'indexes added') {
221-
return updateStatistics.indexesAdded();
221+
return counters.indexesAdded();
222222
}
223223
if (statementString == 'indexes removed') {
224-
return updateStatistics.indexesRemoved();
224+
return counters.indexesRemoved();
225225
}
226226
if (statementString == 'constraints added') {
227-
return updateStatistics.constraintsAdded();
227+
return counters.constraintsAdded();
228228
}
229229
if (statementString == 'constraints removed') {
230-
return updateStatistics.constraintsRemoved();
230+
return counters.constraintsRemoved();
231231
}
232232
if (statementString == 'contains updates') {
233-
return updateStatistics.containsUpdates();
233+
return counters.containsUpdates();
234234
}
235235
throw Error("No statistics mapping of: " + statementString)
236236
}

0 commit comments

Comments
 (0)