MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / Result

Class Result

lib/mapping/result.js:29–136  ·  view source on GitHub ↗

* Represents the result of an execution as an iterable of objects in the Mapper. * @alias module:mapping~Result

Source from the content-addressed store, hash-verified

27 * @alias module:mapping~Result
28 */
29class Result {
30 /**
31 * Creates a new instance of Result.
32 * @param {ResultSet} rs
33 * @param {ModelMappingInfo} info
34 * @param {Function} rowAdapter
35 */
36 constructor(rs, info, rowAdapter) {
37 this._rs = rs;
38 this._info = info;
39 this._rowAdapter = rowAdapter;
40
41 /**
42 * When there is a single cell containing the result of the a LWT operation, hide the result from the user.
43 * @private
44 */
45 this._isEmptyLwt = (rs.columns !== null
46 && rs.columns.length === 1 && this._rs.rowLength === 1 && rs.columns[0].name === '[applied]');
47
48 /**
49 * Gets the amount of the documents contained in this Result instance.
50 * <p>
51 * When the results are paged, it returns the length of the current paged results not the total amount of
52 * rows in the table matching the query.
53 * </p>
54 * @type {Number}
55 */
56 this.length = this._isEmptyLwt ? 0 : (rs.rowLength || 0);
57
58 /**
59 * A string token representing the current page state of query.
60 * <p>
61 * When provided, it can be used in the following executions to continue paging and retrieve the remained of the
62 * result for the query.
63 * </p>
64 * @type {String}
65 * @default null
66 */
67 this.pageState = rs.pageState;
68 }
69
70 /**
71 * When this instance is the result of a conditional update query, it returns whether it was successful.
72 * Otherwise, it returns <code>true</code>.
73 * <p>
74 * For consistency, this method always returns <code>true</code> for non-conditional queries (although there is
75 * no reason to call the method in that case). This is also the case for conditional DDL statements
76 * (CREATE KEYSPACE... IF NOT EXISTS, CREATE TABLE... IF NOT EXISTS), for which the server doesn't return
77 * information whether it was applied or not.
78 * </p>
79 */
80 wasApplied() {
81 return this._rs.wasApplied();
82 }
83
84 /**
85 * Gets the first document in this result or null when the result is empty.
86 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected