145 lines
3.3 KiB
HTML
145 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: Result.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: Result.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>const Helpers = require('./Helpers');
|
|
|
|
/**
|
|
* Query result object
|
|
*
|
|
* @param {Array} rows - the data rows of the result
|
|
* @param {Array} columns - the column names in the result
|
|
*/
|
|
class Result {
|
|
/**
|
|
* Create a result object
|
|
*
|
|
* @private
|
|
* @param {Array} [rows] - the data rows of the result
|
|
* @param {Array} [columns] - the column names in the result
|
|
*/
|
|
constructor (rows = [], columns = []) {
|
|
this._rows = rows;
|
|
this._columns = columns;
|
|
|
|
// If columns aren't explicitly given,
|
|
// get the list from the first row's keys
|
|
if (
|
|
this._columns.length === 0 &&
|
|
this._rows.length > 0 &&
|
|
Helpers.isObject(rows[0])
|
|
) {
|
|
this.columns = Object.keys(rows[0]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return the result rows
|
|
*
|
|
* @private
|
|
* @return {Array} - the data rows of the result
|
|
*/
|
|
get rows () {
|
|
return this._rows;
|
|
}
|
|
|
|
/**
|
|
* Set the result rows for the result object
|
|
*
|
|
* @private
|
|
* @param {Array} rows - the data rows of the result
|
|
* @return {void}
|
|
*/
|
|
set rows (rows) {
|
|
this._rows = rows;
|
|
}
|
|
|
|
/**
|
|
* Return the result columns
|
|
*
|
|
* @private
|
|
* @return {Array} - the column names in the result
|
|
*/
|
|
get columns () {
|
|
return this._columns;
|
|
}
|
|
|
|
/**
|
|
* Set the result columns for the result object
|
|
*
|
|
* @private
|
|
* @param {Array} cols - the array of columns for the current result
|
|
* @return {void}
|
|
*/
|
|
set columns (cols) {
|
|
this._columns = cols;
|
|
}
|
|
|
|
/**
|
|
* Get the number of rows returned by the query
|
|
*
|
|
* @return {Number} - the number of rows in the result
|
|
*/
|
|
rowCount () {
|
|
return this._rows.length;
|
|
}
|
|
|
|
/**
|
|
* Get the number of columns returned by the query
|
|
*
|
|
* @return {Number} - the number of columns in the result
|
|
*/
|
|
columnCount () {
|
|
return this._columns.length;
|
|
}
|
|
}
|
|
|
|
module.exports = Result;
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-drivers_MariaDB.html">drivers/MariaDB</a></li><li><a href="module-drivers_MSSQLDriver.html">drivers/MSSQLDriver</a></li><li><a href="module-drivers_Mysql.html">drivers/Mysql</a></li><li><a href="module-drivers_Pg.html">drivers/Pg</a></li><li><a href="module-drivers_Sqlite.html">drivers/Sqlite</a></li></ul><h3>Classes</h3><ul><li><a href="NodeQuery.html">NodeQuery</a></li><li><a href="QueryBuilder.html">QueryBuilder</a></li><li><a href="Result.html">Result</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Feb 12 2018 14:58:25 GMT-0500 (EST)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|