Is there support to receive a result as an associative array or a result set as an array of associative arrays? I have searched Google and GitHub without finding references to this, so I am assuming not, but just checking in case.
JavaScript has no associative arrays, just objects
Sorry, I can rephrase: Can pg-promise return a result set as an array of objects where the property names are the column names?
eg:
[{
"name": "Joe",
"age": 20
}, {
"name": "Mike",
"age": 25
}]
I use the term associative array because everything in Javascript is an associative array, even an object. Also because the common PHP/MySQL makes heavy use of associative arrays, so it might have been an easier reference point to related to for some.
Wikipedia "In JavaScript an object is a mapping from property names to values鈥攖hat is, an associative array "
https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(associative_array)#JavaScript
"The whole of the JavaScript language is built on one central data structure - the associative array. Objects in JavaScript are just associative arrays and this causes a lot of confusion at first. But the fact of the matter is that the associative array is used to build every other type of data structure in JavaScript."
https://www.i-programmer.info/programming/javascript/1441-javascript-data-structures-the-associative-array.html
My mistake, pg-promise already always returns the query result as an array of objects .
It was just my specific case with a PostgreSQL function that returns a record that wasn't.
Thanks again and sorry for the obvious question.