title: Firebase security rule that limits writes to an increment (+1) of current value?
body: <p>I'm building a very simple JavaScript-based Firebase app that increments a key's value by 1 whenever my webpage is loaded. I don't want any authentication friction, so want to use either an open database, or one restricted to anonymous authentications. So, for example's sake:</p>
  
  <pre><code>$(document).ready(function() {
    // after config and initialize...
    var fb = firebase.database();
    var fbCount = fb.ref("count");
  
    fbCount.transaction(function(current) {
      return current + 1;
    });
  });
  </code></pre>
  
  <p>In either case, as I understand it, there is nothing to stop anyone who can access the page from copying my code (including my initialization config) and using it on their own server--with adjustments--to not only increment the value (<code>fbCount</code> above), but to change the code in any other way they like (e.g. letting them increment the value by 100, 1000, or changing it to something else entirely).</p>
  
  <p>My further understanding is that the best way to deal with this potential is through security rules. So what I'm trying to figure out is whether there's a way, through the security rules, to limit any write to <em>only</em> an increment by 1 of the current value?</p>
  
  <p>If not, is there another method I should be investigating?</p>