asfernandes / node-firebird-drivers

Node.js Firebird Drivers
MIT License
53 stars 17 forks source link

Implementation for #30 : Fetching columns labels #45

Closed mreis1 closed 4 years ago

mreis1 commented 4 years ago

How it works:

....
let resultSet = await attachment.executeQuery(transaction1, 'SELECT 1 AS C FROM RDB$DATABASE');
        let r = await resultSet.fetchAs({ json: true });
        await resultSet.close();
        log('::r', r); // => r { rows: [ { C: 1 } ], columns: [ 'C' ] }

        let resultSet2 = await attachment.executeQuery(transaction1, 'SELECT CURRENT_DATE AS C, 2 as b FROM RDB$DATABASE');
        let r2 = await resultSet2.fetchAs({ json: false });
        await resultSet2.close();
        log('::r2', r2); // => r2 { rows: [ [ 2019-12-09T23:00:00.000Z, 2 ] ],columns: [ 'C', 'B' ] }

        let r3 = await attachment.executeReturning(transaction1, 'SELECT CURRENT_DATE AS C, 2 as b FROM RDB$DATABASE');
        log('::r3', r3); // r3 [ 2019-12-09T23:00:00.000Z, 2 ]

        let r4 = await attachment.executeReturningAs(transaction1, 'SELECT CURRENT_DATE AS C, 2 as b FROM RDB$DATABASE', null, {json: true});
        log('::r4', r4);
        // r4 { cols: [ 'C', 'B' ], row: { C: 2019-12-09T23:00:00.000Z, B: 2 } }

...
NicoAiko commented 4 years ago

@asfernandes Having the possibility to return the results as JSON is elementary imo. Would it be possible to look into this asap?

asfernandes commented 4 years ago

@asfernandes Having the possibility to return the results as JSON is elementary imo. Would it be possible to look into this asap?

I'm in the process of reviewing and improving the API. I'll merge it when I feel confident that the changes will not have future breakings.

mreis1 commented 4 years ago

I'm in the process of reviewing and improving the API. I'll merge it when I feel confident that the changes will not have future breakings.

@asfernandes please let me know if you need me to update something on my implementation. Also, if there are things that you need to discuss, please, let me know.

As @NicoAiko said, this feature is a must for many of us. 😄