You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current sql query api in node.js is returning a resultset and we have to iterate over it and create final key:value json object. I propose it return a json with key:value pairs in result data. The SQL REST API already returns a json (Even though it doesn't return a key value pair).
Motivation
This is to stop us from running into memory issues when the result set is large and the for loop runs for too long.
const result = await client.sql.query({
query: "SELECT * FROM \"game-of-thrones\" WHERE house='stark'"
})
console.log(result)
const data = result.rows.map(row => {
const obj = {}
for (let i = 0; i < row.length; i++) {
obj[result.columns[i].name] = row[i]
}
return obj
})
console.log(data)
Proposed code is this instead of the user iterating on the resultset to make the final JSON, can we have the result.data as a JSON response, which is const data as per the above example.
The text was updated successfully, but these errors were encountered:
Hello! The client returns the response as Elasticsearch crafts them, and it cannot change them.
You are asking more of a helper, which currently doesn't exist for SQL.
I'll mark this as a feature request and think about it.
馃殌 Feature Proposal
Current sql query api in node.js is returning a resultset and we have to iterate over it and create final key:value json object. I propose it return a json with key:value pairs in result data. The SQL REST API already returns a json (Even though it doesn't return a key value pair).
Motivation
This is to stop us from running into memory issues when the result set is large and the for loop runs for too long.
Example
Existing code is this (picked from here)
Proposed code is this instead of the user iterating on the resultset to make the final JSON, can we have the result.data as a JSON response, which is
const data
as per the above example.The text was updated successfully, but these errors were encountered: