title: Upsert in N1QL: How to count-up a value of an existing document
body: <p>I want to INSERT a document based on unique key or UPDATE a counter if the document already exists.</p>
  
  <p>In the <a href="http://docs.couchbase.com/developer/n1ql-dp4/topics/upsert.html" rel="nofollow">UPSERT documentation of DP4</a> I found an example that indicates that UPSERT is more like an INSERT or REPLACE. </p>
  
  <pre><code>UPSERT INTO product (KEY, VALUE) 
  VALUES ("EAN1234567", 
          { "productId": "EAN1234567", "counter": 1}) 
  RETURNING * ;
  </code></pre>
  
  <p>How can I increment the counter of an existing entry within an UPSERT?</p>