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

Contains the returned value of a SQL query.

Platform Support

Jaxer Server FrameworkJaxer Client Framework
1.0no

Constructors

ConstructorActionJaxer Server FrameworkJaxer 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(). The rowsAsArray array is similar to the rows array but each row in it is an array itself: it consists of the cells in that row, in the same order as the columns 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 Details1.0no

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(). The rowsAsArray array is similar to the rows array but each row in it is an array itself: it consists of the cells in that row, in the same order as the columns 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.ResultSetReturns an instance of ResultSet.

Properties

PropertyActionJaxer Server FrameworkJaxer 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.0no
finalRow : Array
This returns the data in the last row of the resultSet as an object, or else it contains an empty object. (You can disambiguate DB nulls from no data by checking the hasData property or rows.length).
No Details 1.0no
firstRow : Array
An alias of the Jaxer.DB.ResultSet.prototype.singleRow method
Show Details1.0no
See Also

Jaxer.DB.ResultSet.prototype.singleRow

hasData : Boolean
True if this resultSet contains any data, false otherwise.
No Details 1.0no
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.
No Details 1.0no
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.0no
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.0no
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.0no
singleRow : Array
This contains the data in the first row of the resultSet as an object, or else it contains an empty object. (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.0no

Functions

MethodActionJaxer Server FrameworkJaxer Client Framework
addRow(Object row) : void
Adds a row, where its structure is assumed to be the same as all the other rows.
Show Details1.0no

Parameters
ObjectrowThe row to add

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

Parameters
Numberidentifiesthe 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
ArrayA 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 Details1.0no

Parameters
Functionfn

Returns
Boolean

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

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

Returns
ArrayAn 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 Details1.0no

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

Returns
ObjectThe 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 Details1.0no

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

Returns
ObjectThe value of the field (column)

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

Returns
NumberThe 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 Details1.0no

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

Returns
StringThe 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 Details1.0no

Parameters
FunctionfnFunction 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 Details1.0no

Parameters
Numberidentifiesthe 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
ArrayA 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 Details1.0no

Parameters
FunctionfnFunction 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 Details1.0no

Parameters
Numbercolumn
Objectvalue
NumberfromIndex

Returns
Number

indexOfColumn(String columnName) : Number
Returns the index of the column with the given name
Show Details1.0no

Parameters
StringcolumnNameThe textual name of the database column

Returns
NumberThe 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 Details1.0no

Returns
Booleantrue 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 Details1.0no

Parameters
Numbercolumn
Objectvalue
NumberfromIndex

Returns
Number

lastRowAsArray() : void
An alias of the Jaxer.DB.ResultSet.prototype.finalRowAsArray method
Show Details1.0no
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 Details1.0no

Parameters
Functionfn

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.0no
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 Details1.0no

Parameters
Functionfn
ObjectinitialValue

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 Details1.0no

Parameters
Functionfn
ObjectinitialValue

Returns
Object

An alias of the Jaxer.DB.ResultSet.prototype.singleRowAsArray method
Show Details1.0no
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 Details1.0no

Parameters
Numberidentifiesthe 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
ArrayA 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 Details1.0no

Parameters
Functionfn

Returns
Boolean

split(Function fn) : 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 Details1.0no

Parameters
Functionfn

Returns
Array[]

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

Parameters
ObjecttableAttributes(optional)An optional hashmap which will be turned into attribute-value pairs on the table tag
ObjectheadingAttributes(optional)An optional hashmap which will be turned into attribute-value pairs on the thead tag
ObjectbodyAttributes(optional)An optional hashmap which will be turned into attribute-value pairs on the tbody tag

Returns
StringHTML table snippet containing the resultset items

toString() : String
Returns a string representation of the resultset object
Show Details1.0no

Returns
StringA 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.rowsAsArrays[10][2]

aptana_docs