title: Rest API Patch only 1 field at a time
body: <p>I'm working on an inline grid editor that calls an express rest api after a single value in the grid is updated.  So when a user changes a single field in the grid, I am calling a <code>PATCH</code> request to update the field.  However I can't figure out how to only update a single field.  When I try it tries to update them all and if there's no value it makes the value NULL in the database.  I want to only update a single field, and only the one passed into the API (it could be any of the fields).  Here's my method to patch:</p>
  
  <pre><code>// Update record based on TxnID
  router.patch('/editablerecords/update', function (req, res) {
      let qb_TxnID = req.body.txnid
      let type = req.body.type;
      let margin = req.body.margin;
  
  
  
      if (!qb_TxnID) {
          return res.status(400).send({ error:true, message: 'Please provide TxnID' });
      }
  
      connection.query("UPDATE pxeQuoteToClose SET ? WHERE qb_TxnID = '" + qb_TxnID + "'", { type, margin  }, function (error, results, fields) {
          if(error){
              res.send(JSON.stringify({"status": 500, "error": error, "response": null })); 
              //If there is error, we send the error in the error section with 500 status
          } else {
              res.send(JSON.stringify({ error: false, data: results, message: 'Record updated.' }));
              //If there is no error, all is good and response is 200OK.
          }
      });
  });
  </code></pre>
  
  <p>I will only be updating 1 field at a time, either <code>type</code> or <code>margin</code>, but not both (in this case) at the same time.  If I only send one of the fields, the other field becomes null.  I've tried to read up on the <code>connection.query()</code> method but can find no information and I don't understand how it builds the query, except that every <code>req.body.value</code> that is passed to it gets used to build the query.</p>
  
  <p>I'm new to building this REST API and feel like I'm missing something simple.</p>
  
  <p>EDIT: I'd like to add, I MAY want to update both fields, but I'd also like to update a single field at a time.  Thanks</p>