Search code examples
node.jsknex.jsnode-oracledb

knex - Raw query execute - how to get the db result along with data type


while execute the raw query using knex (oracle) npm, how to get the data type of the each column along with the result.

select name,age from customers;

when we execute this as raw query using nodejs we can get the selected columns as array result.

rows:[{name: 'SAM', age: 35},{name:'IMRAN',age:25}]

I need data and also the data type of the each column along with the result of the raw query.

Expected Result:

{ "result": { "rows": [{ "name": "SAM", "age": 35 }, { "name": "IMRAN", "age": 25 }], "columns_details": { "name": "varchar 2(32)", "age": "number(2)" } } }

Is there any option is available to get the above result?pls suggest me to get this requirement.

thanks in advance.


Solution

  • With knex.raw queries some drivers might return also datatype information. Knex doesn't provide any special support for that though, so you need to check node-oracledb documentation how to get that column metadata.