Module: RowResult

Relational table API for retrieving data.
Mixes In:
Source:

Methods

fetchAll() → {Array.<Array>}

Consume the current result-set from memory (and flush it).
Source:
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() → {Array}

Consume a single result-set row from memory (and flush it).
Source:
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']
  })

getColumns() → {Array.<module:Column>}

Retrieve the list of columns that are part of the result-set.
Source:
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() → {Array.<Array.<Array>>}

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

nextResult() → {boolean}

Move to the next available result-set.
Source:
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.fetcOne())
    } while (res.nextResult())
  })

toArray() → {Array}

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