Closed pupupulp closed 4 years ago
I suppose you want [{ column1: value1, column2: value2 }, ...]
instead of [[value1, value2], ...]
?
yes yes thats it, is it possible to have an output like this [{ column1: value1, column2: value2 }, ...]
?
it would be a lot of help if we could get the result in that format, i checked through the code and examples but i cant seem to find how to do it using entirely the library, right now we created a separate array for the keys and used reduce function but it seems slow and takes a lot of processing time specially when the result set is large
I must agree that this would be very helpful, specially if we rely on wildcards to fetch all the columns from a given table.
A suggestion would be to pass a "options object" to methods such as:
@asfernandes do you have any thoughts on this?
There's an implementation for this on xdenders lib. Maybe this can inspire you on how to implement this piece of functionality.
https://github.com/xdenser/node-firebird-libfbclient/blob/master/src/fb-bindings-fbresult.cc#L585
I realize that there's an issue with my initial proposal.
Since executeQuery doesn't fetch results, the json propery should be set at
resultSet.fetch({fetchSize?: number; json?: boolean})
Since executeReturning, automatically fetches the resultSet, then json property must be set as follows:
attachment.executeReturning(tx, sqlStmt, params, { json?: boolean; prepareOptions?, executeOptions? })
Is there any way to return headers along with the result set rows or format the result set rows along with the header?
something like this
{ header1: value1, header2: value2, header3: value3 }
the rows i get only have
{ value1, value2, value3 }