Skip to content

Return results as an array of arrays. #477

@peterv959

Description

@peterv959

This package works very nicely for my needs. I'm not sure how effective it may be in a high-demand environment, but my needs are straightforward.

I want to use this on an AS/400 DB2 server, and some of the results can be pretty lengthy. Also, in my environment, the VARCHAR types all have trailing spaces. Consequently, I wanted to shrink the payload from node-adodb back to my server app. I have gone in and added an optional parameter to the query() method call. FetchArrays is the optional parameter. It is a Boolean type. When true, the return results are packaged as a record type in the following structure:

json

{
    FieldMetaData: {
        FieldNames: [ "Field 1", "Field 2" ],
        FieldTypes: [ 3,7 ]
    },
    Results: [ [ "Field 1 Value", "Field 2 Value" ], [ "Field 1 Value", "Field 2 Value" ] ]
}

The structure is reminiscent of the ADODB.Recordset type.

I have made these changes pending acceptance. I bumped the version and adjusted the README-EN and CHANGELOG files.

I am strongly toying with the idea of adding a parameterized version of the query. I could use SELECT parameters for some future projects. If anyone is interested in such a thing let me know. To do this right, I would need to deal with how to make that work on a larger scale than I would need. For example, what are "Output" parameters? I'm not fluent enough with SQL to even guess when I would need such a thing. There are five optional settings for ADODB.Parameter types. Since they are optional, I would probably just implement the InputDirection and a limited number of DataTypes (VARCHAR, INTEGER, DATE are the ones I'm thinking about. I could certainly pass thru the ones I don't implement or check for and leave it to the user as an exercise to ensure the data is compliant for her/his needs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions