OpenInformix / IfxNode

Informix native node.js driver for scalable enterprise and IoT solutions.
MIT License
9 stars 11 forks source link

Feature request: Is it possible to bind pair columns|values from array? #3

Open lemano opened 6 years ago

lemano commented 6 years ago

Hi, I'm trying to make an update in a table, however, I would like to have a generic update function. Is it possible to add a binding feature that kind of expands an object with column names and values?

Something like

{ cor_cod:"18 " cor_codcons:"BR1" cor_codconst:"Y7Y7" cor_coddga:"0416" cor_coddgv:"1" }

, in that, it would bind to something like:

cor_cod = 18, cor_codcons:"BR1", ....

, replacing '?' character. I've seen this feature in a mysql driver.

Thanks

msatyan commented 6 years ago

Hi Lemano,

Thanks for the suggestion, certainly such facility will make user-friendly. We will certainly take this topic for discussion. The node.js driver sit on top of Informix ODBC driver, where the ODBC driver do not support named parameters support functionality, I wish it was. Without such support from ODBC, it will be significant effort for the nodejs driver to introduce such support. By any chance if you know any opensource nodejs driver that has implemented functionality fully on node layer please let us know. We could pull those changes to save time and effort.

Regards, Satyan.

lemano commented 6 years ago

Hi @msatyan,

sorry, I hadn't seen your answer earlier. So, the driver I was referring it's the one in the following link:

nodejs - mysql,

, you can check the behaviour in the this section, more exactly on this example:

var post  = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function (error, results, fields) {
  if (error) throw error;
  // Neat!
});

If you check the example above, it is given an object with named properties to query function. I'll try to make a more detailed search in the code.