title: NodeJS and pg-promise, insert dynamically from JSON-object
body: <p>I'm running NodeJS and pg-promise, and are trying to accomplish somethings like:</p>
  
  <pre><code>db.none('INSERT INTO my-table (JSON-object-keys) VALUES ($1)', [JSON-object-values])
      .catch(function(err) {
          console.log('Error on insert into my-table: ' + err);
      });
  </code></pre>
  
  <p>I have JSON-objects which can look like:</p>
  
  <pre><code>{"column1":"value1", "column2":"value2", "column3":"value3"}
  {"column2":"value2", "column3":"value3"}
  {"column1":"value1", "column3":"value3"}
  </code></pre>
  
  <p>I would like to have the INSERTS automatically generated corresponding to what the JSON-object contains.</p>
  
  <p>Is that possible in an elegant way?</p>
  
  <p>Explained a bit more, in the 3 examples of JSON the following should be generated:</p>
  
  <pre><code>db.none('INSERT INTO my-table (column1, column2, column3) VALUES ($1, $2, $3)', [value1, value2, value3])
      .catch(function(err) {
          console.log('Error on insert into my-table: ' + err);
      });
  
  db.none('INSERT INTO my-table (column2, column3) VALUES ($1, $2)', [value2, value3])
      .catch(function(err) {
          console.log('Error on insert into my-table: ' + err);
      });
  
  db.none('INSERT INTO my-table (column1, column3) VALUES ($1, $2)', [value1, value3])
      .catch(function(err) {
          console.log('Error on insert into my-table: ' + err);
      });
  </code></pre>