sagiegurari / simple-oracledb

Extend capabilities of oracledb with simplified API for quicker development.
Apache License 2.0
36 stars 4 forks source link

Will you support promise on query, insert and update methods ? #7

Closed lucasmartinez closed 8 years ago

lucasmartinez commented 8 years ago

Problem Description

query method is not returning a Promise.

Code Example

var simpleOracledb = require('simple-oracledb'), oracledb = require('oracledb');

simpleOracledb.extend(oracledb);

oracledb.createPool({ user: 'user', password: 'password', connectString: "127.0.0.1/orcl" }).then(function (dbpool) { dbpool.getConnection().then(function (conection) { conection.query('select sysdate from dual').then(function(r){ console.log(r); }) }); });

//paste code here

Error Stack/Info (if any)

/home/oracle/hermes/node_modules/simple-oracledb/lib/rows-reader.js:49 callback(error, jsRows); ^

TypeError: callback is not a function at onAyncDone (/home/oracle/hermes/node_modules/simple-oracledb/lib/rows-reader.js:49:13) at /home/oracle/hermes/node_modules/async/dist/async.js:3679:13 at /home/oracle/hermes/node_modules/async/dist/async.js:952:25 at iteratorCallback (/home/oracle/hermes/node_modules/async/dist/async.js:997:17) at /home/oracle/hermes/node_modules/async/dist/async.js:847:20 at /home/oracle/hermes/node_modules/async/dist/async.js:3676:17 at /home/oracle/hermes/node_modules/async/dist/async.js:339:31 at onRowRead (/home/oracle/hermes/node_modules/simple-oracledb/lib/rows-reader.js:42:25) at onAyncDone (/home/oracle/hermes/node_modules/simple-oracledb/lib/record-reader.js:117:9) at /home/oracle/hermes/node_modules/async/dist/async.js:3679:13

sagiegurari commented 8 years ago

wasn't planning to since I prefer async lib, but I can do that since I see many wanted it for orabledb. so guess in around a day or 2 I'll publish something.

lucasmartinez commented 8 years ago

Great job. Your library helped me a lot. I would like to use Promise in all my server functions to standarize the way my product is developed having Promise in front aplication and in my backend too. This way the code in front and backend are the same.

sagiegurari commented 8 years ago

All done and published (version 0.1.95) Please check on your end that it works good.

sagiegurari commented 8 years ago

version 0.1.97 now also automatically promisify any extension on top simple-oracledb, for example oracledb-upsert

lucasmartinez commented 8 years ago

Bravo. Great Job.

lucasmartinez commented 8 years ago

One more question. Is there any way to log all executed querys ? Now I have a custom function to show in the console the execute query or PL/SQL block. But I would like to activate some DEBUG flag globally to show or hide the executed query by any function.

sagiegurari commented 8 years ago

I can add it. should be very simple. will do it probably tomorrow using the debug flag https://github.com/sagiegurari/simple-oracledb/#debug

lucasmartinez commented 8 years ago

Great. I suggest to add some debug level to show the sentence ( one debug level ) and bind values ( another debug level ). maybe some extra values like connected user, date, hour, etc.

sagiegurari commented 8 years ago

if you are now running with the NODE_DEBUG flag, all SQLs that go through the connection.execute (that means also all extended connection operations such as query/insert/batchXXX etc...) will be printed with bind params. However, it does not cover the connection.queryStream function found in the oracledb connection object since I don't use it in simple-oracledb (although funny thing is that I wrote it for oracledb via pull request). Hope it solves your issue. If there are problems with that debug printing, please open a new issue.