-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get results as records - an array of objects. #84
Comments
There are A related idea is to add a In both of the above cases, there is a complication that column names in results are not necessarily unique. Non-unique column names can happen fairly often, for example when performing joins. DuckDB has a pattern for making column names unique by appending a number preceded by an underscore (e.g. Currently, the data values returned by For the above, are you more interested in JS built-ins, or JSON serializability? For example, there are a few reasonable transformations for TIMESTAMP values: the raw epoch value (in microseconds) as a |
Yes, sir! What I've been doing so far is getting back the For my use case, most values don't actually need parsing. It's the date, timestamp, etc., types that I'm having to address. You make a great point about JS primitives vs. JSON serializability. My use case would lean more towards JSON serializable. In future, more complicated, data pulls, I'd love have the complex types unfurl into nested JSON serializable objects; i.e., lists, arrays, and structs represented in the record as a nested object:
That makes a ton of sense to me!
TIMESTAMP makes a lot of sense as a lot sense, especially the full format. DECIMAL I'm much less confident in. Would definitely be best to have customizable options there. SIDE NOTE: I did notice an unexpected result in node-neo when running
Could definitely be useful! I don't personally have an immediate use case but I could definitely picture some. |
Thanks for the context! It helps me understand how to best support this. Also thanks for the reminder about the TIMESTAMPTZ |
I was stuck with the same problem. Had to implement it all by hand. Do review it once as I wrote it in very short time. cc: @jraymakers See if this kind of conversion can be included in some utility api in node package itself. |
Yes, I consider this issue to track supporting an easy way to construct a JSON-serializable representation of a result. It's a good point that there should be a way to do that for the column names & types as well. That shouldn't be hard to include. |
Thanks @freakynit! @jraymakers - Testing out passing the timestamptz string value to Going through the process of creating a result parser, the more I appreciate a lot of the potential decision points. I was originally concerned with the timestamp types since they provide micros instead of millis, but as mentioned above passing the I do think I'll have another function to create an array of arrays version of serializable results, too, if I could humbly suggest that as a utility as well. Honestly, I think I almost immediately have a use case for having all 3 possible results discussed - serializable array of records, serializable array of arrays, and the standard array of arrays result in DuckDB types - right out of the gate. Thanks again for all your help! |
Similar to how node-postgres returns results by default. The fact that it isn't the default isn't a problem, only that it's available. The wide variety of DuckDB data types makes this more difficult proposition than it might seem. Ideally the values would be in a JS native type for use and presentation, no longer as a DuckDBValue type.
The text was updated successfully, but these errors were encountered: