es6/api/results/index.js
/**
 * Create a plain javascript array containing objects
 * representing name value pairs of the results.
 * @param {array} results An array from the results fields
 * of rqlite response.
 * @param {object} options Options for the function
 * @param {boolen} options.valuesAsArrays Preserve
 * the values as an array of arrays, defaults to a single
 * array of objects.
 */
Create a plain javascript array containing objects
representing name value pairs of the results.
@param {array} results An array from the results fields
of rqlite response.
@param {object} options Options for the function
@param {boolen} options.valuesAsArrays Preserve
the values as an array of arrays, defaults to a single
array of objects.
Create a plain javascript array containing objects representing name value pairs of the results . @param { array } results An array from the results fields of rqlite response . @param { object } options Options for the function @param { boolen } options . valuesAsArrays Preserve the values as an array of arrays defaults to a single array of objects .
function toPlainJs(results = [], options = {}) {
  const { valuesAsArrays } = options
  return _reduce(results, (reduction, result, resultIndex) => {
    const columns = _get(result, 'columns', [])
    const values = _get(result, 'values', [])
    const nvpResults = _map(
      values,
      value => _mapKeys(value, (val, index) => _get(columns, index)),
    )
    if (valuesAsArrays) {
      _set(reduction, resultIndex, nvpResults)
      return reduction
    }
    return _concat(reduction, nvpResults)
  }, [])
}
function toPlainJs ( results = [ ] , options = { } ) { const { valuesAsArrays } = options return _reduce ( results , ( reduction , result , resultIndex ) => { const columns = _get ( result , 'columns' , [ ] ) const values = _get ( result , 'values' , [ ] ) const nvpResults = _map ( values , value => _mapKeys ( value , ( val , index ) => _get ( columns , index ) ) , ) if ( valuesAsArrays ) { _set ( reduction , resultIndex , nvpResults ) return reduction } return _concat ( reduction , nvpResults ) } , [ ] ) }
Create a plain javascript array containing objects
 representing name value pairs of the results.
Create a plain javascript array containing objects representing name value pairs of the results .
// Map each of the values onto an object with the // column name as the key and the values as the value // Keep the orginal array of arrays of objects result structure // Collapse results to an array of objects