17
17
* limitations under the License.
18
18
*/
19
19
20
- import { int , isInt } from './integer' ;
20
+ import { isInt } from './integer' ;
21
21
22
22
/**
23
23
* A ResultSummary instance contains structured metadata for a {Result}.
@@ -31,19 +31,79 @@ class ResultSummary {
31
31
* @param {Object } metadata - Statement metadata
32
32
*/
33
33
constructor ( statement , parameters , metadata ) {
34
+ /**
35
+ * The statement and parameters this summary is for.
36
+ * @type {{text: string, parameters: Object} }
37
+ * @public
38
+ */
34
39
this . statement = { text : statement , parameters} ;
40
+
41
+ /**
42
+ * The type of statement executed. Can be "r" for read-only statement, "rw" for read-write statement,
43
+ * "w" for write-only statement and "s" for schema-write statement.
44
+ * String constants are available in {@link statementType} object.
45
+ * @type {string }
46
+ * @public
47
+ */
35
48
this . statementType = metadata . type ;
36
- let counters = new StatementStatistics ( metadata . stats || { } ) ;
37
- this . counters = counters ;
49
+
50
+ /**
51
+ * Counters for operations the statement triggered.
52
+ * @type {StatementStatistics }
53
+ * @public
54
+ */
55
+ this . counters = new StatementStatistics ( metadata . stats || { } ) ;
38
56
//for backwards compatibility, remove in future version
39
- this . updateStatistics = counters ;
57
+ this . updateStatistics = this . counters ;
58
+
59
+ /**
60
+ * This describes how the database will execute the statement.
61
+ * Statement plan for the executed statement if available, otherwise undefined.
62
+ * Will only be populated for queries that start with "EXPLAIN".
63
+ * @type {Plan }
64
+ */
40
65
this . plan = metadata . plan || metadata . profile ? new Plan ( metadata . plan || metadata . profile ) : false ;
66
+
67
+ /**
68
+ * This describes how the database did execute your statement. This will contain detailed information about what
69
+ * each step of the plan did. Profiled statement plan for the executed statement if available, otherwise undefined.
70
+ * Will only be populated for queries that start with "PROFILE".
71
+ * @type {ProfiledPlan }
72
+ * @public
73
+ */
41
74
this . profile = metadata . profile ? new ProfiledPlan ( metadata . profile ) : false ;
75
+
76
+ /**
77
+ * An array of notifications that might arise when executing the statement. Notifications can be warnings about
78
+ * problematic statements or other valuable information that can be presented in a client. Unlike failures
79
+ * or errors, notifications do not affect the execution of a statement.
80
+ * @type {Array<Notification> }
81
+ * @public
82
+ */
42
83
this . notifications = this . _buildNotifications ( metadata . notifications ) ;
84
+
85
+ /**
86
+ * The basic information of the server where the result is obtained from.
87
+ * @type {ServerInfo }
88
+ * @public
89
+ */
43
90
this . server = new ServerInfo ( metadata . server ) ;
91
+
92
+ /**
93
+ * The time it took the server to consume the result.
94
+ * @type {number }
95
+ * @public
96
+ */
44
97
this . resultConsumedAfter = metadata . result_consumed_after ;
98
+
99
+ /**
100
+ * The time it took the server to make the result available for consumption in milliseconds.
101
+ * @type {number }
102
+ * @public
103
+ */
45
104
this . resultAvailableAfter = metadata . result_available_after ;
46
105
}
106
+
47
107
_buildNotifications ( notifications ) {
48
108
if ( ! notifications ) {
49
109
return [ ] ;
0 commit comments