Module: RowResult

Relational table API for retrieving data.
Mixes In:

Methods


fetchAll()

Consume the current result set from memory (and flush it).
Returns:
A list of rows.
Type
Array.<Array>
Example
table.select()
  .execute()
  .then(res => {
    // get the list of documents in the result set
    var rows = res.fetchAll()
  })

session.sql("SELECT 'foo'")
  .execute()
  .then(res => {
    console.log(res.fetchAll()) // [['foo']]
  })

fetchOne()

Consume a single result set row from memory (and flush it).
Returns:
A row.
Type
Array
Example
table.select()
  .execute()
  .then(res => {
    // iterate over the documents in the result set
    while (var row = res.fetchOne()) {
      // do something with the current document
    }
  })

session.sql("SELECT 'foo'")
  .execute()
  .then(res => {
    console.log(res.fetchOne()) // ['foo']
  })

getAffectedItemsCount()

Retrieve the number of documents affected by the operation.
Returns:
The number of rows.
Type
number

getColumns()

Retrieve the list of columns that are part of the result set.
Returns:
A list of columns.
Type
Array.<module:Column>
Example
session.sql("SELECT 'foo' AS name")
  .execute()
  .then(res => {
    var columns = res.getColumns()
    console.log(columns[0].getColumnLabel()) // name
  })

getResults()

Retrieve the entire result set (without flushing).
Returns:
Type
Array.<Array.<Array>>

nextResult()

Move to the next available result set.
Returns:
Type
boolean
Example
// CREATE PROCEDURE proc() BEGIN
//   SELECT 'foo' as name;
//   SELECT 'bar' as name;
// END
session.sql('CALL proc()')
  .execute()
  .then(res => {
    // iterate over multiple result sets
    do {
      console.log(res.fetchOne())
    } while (res.nextResult())
  })

toArray()

Returns the current result set (without flushing) as a JavaScript Arrray.
Returns:
Type
Array