Skip to content

Commit 6286f3c

Browse files
committed
updateStatistics() -> statistics
1 parent 39bbd11 commit 6286f3c

File tree

3 files changed

+20
-44
lines changed

3 files changed

+20
-44
lines changed

examples/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ streamResult.subscribe({
2929
var summary = streamResult.summarize();
3030
//Print number of nodes created
3131
console.log('');
32-
console.log(summary.updateStatistics().nodesCreated());
32+
console.log(summary.statistics.nodesCreated());
3333
streamSession.close();
3434
}, onError: function(error) {
3535
console.log(error);
@@ -48,7 +48,7 @@ promiseResult.then(function(records) {
4848
var summary = promiseResult.summarize();
4949
//Print number of nodes created
5050
console.log('');
51-
console.log(summary.updateStatistics().nodesCreated());
51+
console.log(summary.statistics.nodesCreated());
5252
})
5353
.catch(function(error) {
5454
console.log(error);

lib/result.js

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -123,33 +123,9 @@ class ResultSummary {
123123
*/
124124
constructor(statement, parameters, statementType, statistics) {
125125
this.statement = statement;
126-
this._parameters = parameters;
126+
this.parameters = parameters;
127127
this.statementType = statementType;
128-
this._statistics = new StatementStatistics(statistics || {});
129-
}
130-
131-
hasPlan() {
132-
133-
}
134-
135-
hasProfile() {
136-
137-
}
138-
139-
plan() {
140-
141-
}
142-
143-
profile() {
144-
145-
}
146-
147-
/**
148-
* Get the statistics
149-
* @return {StatementStatistics}
150-
*/
151-
updateStatistics() {
152-
return this._statistics;
128+
this.statistics = new StatementStatistics(statistics || {});
153129
}
154130
}
155131

@@ -164,23 +140,23 @@ class StatementStatistics {
164140
* @param {Object} statistics - Result statistics
165141
*/
166142
constructor(statistics) {
167-
this._stats = {};
168-
this._stats.nodesCreated = 0;
169-
this._stats.nodesDeleted = 0;
170-
this._stats.relationshipsCreated = 0;
171-
this._stats.relationshipsDeleted = 0;
172-
this._stats.propertiesSet = 0;
173-
this._stats.labelsAdded = 0;
174-
this._stats.labelsRemoved = 0;
175-
this._stats.indexesAdded = 0;
176-
this._stats.indexesRemoved = 0;
177-
this._stats.constraintsAdded = 0;
178-
this._stats.constraintsRemoved = 0;
179-
143+
this._stats = {
144+
nodesCreated: 0,
145+
nodesDelete: 0,
146+
relationshipsCreated: 0,
147+
relationshipsDeleted: 0,
148+
propertiesSet: 0,
149+
labelsAdded: 0,
150+
labelsRemoved: 0,
151+
indexesAdded: 0,
152+
indexesRemoved: 0,
153+
constraintsAdded: 0,
154+
constraintsRemoved: 0
155+
}
180156
Object.keys(statistics).forEach((index) => {
181157
let val = neo4j.isInt(statistics[index]) ? statistics[index].toInt() : statistics[index];
182158
//To camelCase
183-
this._stats[index.replace(/(\-\w)/g, function(m){return m[1].toUpperCase();})] = val;
159+
this._stats[index.replace(/(\-\w)/g, (m) => m[1].toUpperCase())] = val;
184160
});
185161
}
186162

test/session.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ describe('session', function() {
6161
result.then(function( records ) {
6262
var sum = result.summarize();
6363
expect(sum.statement).toBe( statement );
64-
expect(sum.updateStatistics().containsUpdates()).toBe(true);
65-
expect(sum.updateStatistics().nodesCreated()).toBe(1);
64+
expect(sum.statistics.containsUpdates()).toBe(true);
65+
expect(sum.statistics.nodesCreated()).toBe(1);
6666
expect(sum.statementType).toBe('rw');
6767
driver.close();
6868
done();

0 commit comments

Comments
 (0)