Jaxer.DB.ResultSet : Object
Return to: Jaxer Framework index

Contains the returned value of a SQL query.

Platform Support

Jaxer Server Framework Jaxer Client Framework
1.0 no

Constructors

Constructor Action Jaxer Server Framework Jaxer Client Framework
Jaxer.DB.ResultSet Constructor() : Jaxer.DB.ResultSet
Returned value of a SQL query, containing the named rows and columns of the result and to be used as the return value of execute(). Each row has a special property, $values, that is an array ordered according to the columns array. The rowsAsArray array is similar to the rows array but each row in it is an array itself: it is the corresponding $values array. To see if there is any data, check whether hasData is true or whether rows.length or rowsAsArrays.length exceed 0. To get a single result (the first column of the first row) grab singleResult.
Show Details 1.0 no

Jaxer.DB.ResultSet() : Jaxer.DB.ResultSet

Returned value of a SQL query, containing the named rows and columns of the result and to be used as the return value of execute(). Each row has a special property, $values, that is an array ordered according to the columns array. The rowsAsArray array is similar to the rows array but each row in it is an array itself: it is the corresponding $values array. To see if there is any data, check whether hasData is true or whether rows.length or rowsAsArrays.length exceed 0. To get a single result (the first column of the first row) grab singleResult.

Returns
Jaxer.DB.ResultSet Returns an instance of ResultSet.

Properties

Property Action Jaxer Server Framework Jaxer Client Framework
columns : Array
An array of column names for all rows in this resultSet. TODO - Note that (depending on the DB "driver" implementation used) the columns array may be empty if there are no rows of data; this will be fixed in the future.
No Details 1.0 no
finalRow : Array
This returns the data in the last row of the resultSet as an array, or else it contains an empty array. (You can disambiguate DB nulls from no data by checking the hasData property or rows.length).
No Details 1.0 no
firstRow : Array
An alias of the Jaxer.DB.ResultSet.prototype.singleRow method
Show Details 1.0 no
See Also

Jaxer.DB.ResultSet.prototype.singleRow

hasData : Boolean
True if this resultSet contains any data, false otherwise.
No Details 1.0 no
rows : Array
The array of rows in the resultSet in the order retrieved from the database. Each row has properties corresponding to the column names in the returned data. Each row also has a special property, $values, that's an array of the values in that row (in the same order as the columns array).
No Details 1.0 no
rowsAsArrays : Array
An alternate representation of the rows of the resultSet: each row is itself an array, containing the values (cells) in that row in the same order as the columns array.
No Details 1.0 no
singleColumn : Array
This returns the data in each of the first columns of the resultSet as an array, or else it contains an empty array. (You can disambiguate DB nulls from no data by checking the hasData property or rows.length). This is convenient for queries that are used to populate dropdowns.
No Details 1.0 no
singleResult : Object
This contains the first value (cell) in the first row in the resultSet, if any, or else it contains null. (You can disambiguate DB nulls from no data by checking the hasData property or rows.length). This is convenient for queries (e.g. "SELECT COUNT(*) FROM mytable") that are known to return a single value.
No Details 1.0 no
singleRow : Array
This contains the data in the first row of the resultSet as an array, or else it contains an empty array. (You can disambiguate DB nulls from no data by checking the hasData property or rows.length). This is convenient for queries (e.g. "SELECT * FROM mytable where key = 'value'") that are known to return a single value.
No Details 1.0 no

Functions

Method Action Jaxer Server Framework Jaxer Client Framework
addRow(Object row) : void
Adds a row, where its structure is assumed to be the same as all the other rows. Note that in particular it must have a $values property.
Show Details 1.0 no

Parameters
Object row The row to add

close() : void
Closes this resultSet and empties its internal data structures. This is optional.
No Details 1.0 no
columnsAsArray(Number identifies) : Array
This return the data in the provided columns of the resultSet as an array, or else it contains null.
Show Details 1.0 no

Parameters
Number identifies the columns to return, either as an array index value, or a column label value, you can specify 1 or more columns to be returned

Returns
Array A javascript array of arrays containg each of the values of the requested column from the current resultset

every(Function fn) : Boolean
every runs a function against each row in the recordset while that function is returning true. returns true if the function returns true for every row it could visit The function is invoked with three arguments: - the value of the current row in the resultset, - the index of the current row in the resultset, - an array representing the resultset being traversed.
Show Details 1.0 no

Parameters
Function fn

Returns
Boolean

extractColumns(Array columns) : Array
Returns an array of objects, one per row, that only have properties corresponding to the given columns.
Show Details 1.0 no

Parameters
Array columns The names of the columns that should be made available for each row.

Returns
Array An array of simple objects, each with the requested properties.

field(Number fieldIndex) : Object
For the current row pointed to by the cursor, returns the value of the field (column) at the given (0-based) index, the same as this.rowsAsArrays [ currentRowIndex ] [ fieldIndex ] Throws a Jaxer.Exception if fieldIndex is out of range.
Show Details 1.0 no

Parameters
Number fieldIndex The 0-based index of the desired field (column), bounded by this.columns.length.

Returns
Object The value of the field (column)

fieldByName(String fieldByName) : Object
For the current row pointed to by the cursor, returns the value of the field (column) at the given fieldName (column name), the same as this.rows [ currentRowIndex ] [ fieldName ] Throws a Jaxer.Exception if fieldName is not the name of a field (column).
Show Details 1.0 no

Parameters
String fieldByName The name of the desired field (column), which should be an element of the Array this.columns.

Returns
Object The value of the field (column)

fieldCount() : Number
Returns the number of fields (columns) in this resultSet, the same as this.columns.length.
Show Details 1.0 no

Returns
Number The number of fields (columns)

fieldName(Number fieldIndex) : String
Returns the name of the column at the given (0-based) index, the same as this.columns [ fieldIndex ] . Throws a Jaxer.Exception if fieldIndex is out of range.
Show Details 1.0 no

Parameters
Number fieldIndex The 0-based index of the desired field (column), bounded by this.columns.length.

Returns
String The name of the field (column)

filter(Function fn) : Array
filter returns a new array with all of the elements of this array for which the provided filtering function returns true. The function is invoked with three arguments: - the value of the current row in the resultset, - the index of the current row in the resultset, - an array representing the resultset being traversed.
Show Details 1.0 no

Parameters
Function fn Function to test each row of the recordset

Returns
Array

finalRowAsArray(Number identifies) : Array
This contains the requested columns from the last row of the resultSet as an array, or else it contains an empty array.
Show Details 1.0 no

Parameters
Number identifies the columns to return, either as an array index value, or a column label value, you can specify 1 or more columns to be returned

Returns
Array A javascript array the values of the requested columns from the last row of the current resultset

forEach(Function fn) : void
forEach executes the provided function (callback) once for each element present in the recordset. The callback is invoked with three arguments: - the value of the current row in the resultset, - the index of the current row in the resultset, - an array representing the resultset being traversed.
Show Details 1.0 no

Parameters
Function fn Function to execute against each row of the recordset

indexOf(Number column, Object value, Number fromIndex) : Number
indexOf compares the value of the requested column in each row of the results using strict equality (the same method used by the ===, or triple-equals, operator). it returns either the index of the first matched item or -1 if no items match
Show Details 1.0 no

Parameters
Number column
Object value
Number fromIndex

Returns
Number

indexOfColumn(String columnName) : Number
Returns the index of the column with the given name
Show Details 1.0 no

Parameters
String columnName The textual name of the database column

Returns
Number The 0-based index in the columns array (and in each row in the rows array)

isValidRow() : Boolean
True if this resultSet's cursor is positioned on a valid row, which means you can access the row's data.
Show Details 1.0 no

Returns
Boolean true if positioned on a valid row, false otherwise

lastIndexOf(Number column, Object value, Number fromIndex) : Number
indexOf compares the value of the requested column in each row of the results using strict equality (the same method used by the ===, or triple-equals, operator). it returns either the index of the last matched item or -1 if no items match
Show Details 1.0 no

Parameters
Number column
Object value
Number fromIndex

Returns
Number

lastRowAsArray() : void
An alias of the Jaxer.DB.ResultSet.prototype.finalRowAsArray method
Show Details 1.0 no
See Also

Jaxer.DB.ResultSet.prototype.finalRowAsArray

map(Function fn) : Array
map runs a function on every row in the resultset and returns the results in an array. The row and index of the current item are passed as parameters to the current function.
Show Details 1.0 no

Parameters
Function fn

Returns
Array

next() : void
Advances this resultSet's cursor to the next row of results. Use isValidRow() to determine if you've reached the end of the rows.
No Details 1.0 no
reduce(Function fn, Object initialValue) : Object
reduce runs a function on every item in the resultset and collects the results returned. reduce executes the callback function once for each element present in the resultset, receiving four arguments: - the initial value (or value from the previous callback call), - the value of the current row of the resultset, - the current index, - an array representing the resultset over which iteration is occurring.
Show Details 1.0 no

Parameters
Function fn
Object initialValue

Returns
Object

reduceRight(Function fn, Object initialValue) : Object
reduceRight runs a function on every item in the resultset and collects the results returned, but in reverse order starting with the last element of the recordset. reduceRight executes the callback function once for each element present in the resultset, excluding holes in the array, receiving four arguments: - the initial value (or value from the previous callback call), - the value of the current row of the resultset, - the current index, - an array representing the resultset over which iteration is occurring.
Show Details 1.0 no

Parameters
Function fn
Object initialValue

Returns
Object

An alias of the Jaxer.DB.ResultSet.prototype.singleRowAsArray method
Show Details 1.0 no
See Also

Jaxer.DB.ResultSet.prototype.singleRowAsArray

singleRowAsArray(Number identifies) : Array
This contains the requested columns from the first row of the resultSet as an array, or else it contains an empty array.
Show Details 1.0 no

Parameters
Number identifies the columns to return, either as an array index value, or a column label value, you can specify 1 or more columns to be returned

Returns
Array A javascript array the values of the requested columns from the first row of the current resultset

some(Function fn) : Boolean
some runs a function against each row in the recordset while that function until returning true. returns true if the function returns true for at least one row it could visit The function is invoked with three arguments: - the value of the current row in the resultset, - the index of the current row in the resultset, - an array representing the resultset being traversed.
Show Details 1.0 no

Parameters
Function fn

Returns
Boolean

split(Function fn) : Array<Array>
split runs a function against each row in the recordset. returns A two element array containing the recorset items for which the function returned true as the first element and the items which returned false as the 2nd element. The function is invoked with three arguments: - the value of the current row in the resultset, - the index of the current row in the resultset, - an array representing the resultset being traversed.
Show Details 1.0 no

Parameters
Function fn

Returns
Array<Array>

toHTML([Object tableAttributes,] [Object headingAttributes,] [Object bodyAttributes]) : String
Returns a HTML table snippet containing the resultset items
Show Details 1.0 no

Parameters
Object tableAttributes (optional)An optional hashmap which will be turned into attribute-value pairs on the table tag
Object headingAttributes (optional)An optional hashmap which will be turned into attribute-value pairs on the thead tag
Object bodyAttributes (optional)An optional hashmap which will be turned into attribute-value pairs on the tbody tag

Returns
String HTML table snippet containing the resultset items

toString() : String
Returns a string representation of the resultset object
Show Details 1.0 no

Returns
String A string representation of the resultset object

Examples

If the third column is named "account" you can get to a given cell value either through resultSet.rows [ 10 ] .account or through resultSet.rows [ 10 ] .$values [ 2 ] or through resultSet.rowsAsArrays [ 10 ] [ 2 ]

aptana_docs