title: Firestore: Something reseted shard value
body: <p>I'm trying to implement <a href="https://firebase.google.com/docs/firestore/solutions/counters" rel="nofollow noreferrer">shards counters</a> to my app. I have the next firestore collection structure:
  <a href="https://i.stack.imgur.com/7vetS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7vetS.png" alt="enter image description here"></a></p>
  
  <p>When I want to update counter, I call this method:</p>
  
  <pre class="lang-js prettyprint-override"><code>  public updateCounter(ref: DocumentReference, num_shards: number, type: 'inc' | 'dec'): Promise&lt;void&gt; {
      const shard_id = Math.floor(Math.random() * num_shards).toString();
      const shard_ref = ref.collection('shards').doc(shard_id);
  
      return shard_ref.set({
        'count': firestore.FieldValue.increment(type === 'dec' ? -1 : 1)
      }, { merge: true });
    }
  
  </code></pre>
  
  <p>This is the place where I call it:</p>
  
  <pre class="lang-js prettyprint-override"><code>const starsRef = this.fireStore.collection('counters')
                                 .doc('stars')
                                 .collection('companies')
                                 .doc(this.cid).ref
  
  this.countersService.updateCounter(starsRef, 5, 'inc')
  </code></pre>
  
  <p>But the problem, every time I make a call, it's increment <code>count</code> value of random shard, but also, it reset count to 0 for all other shards. I can't understand, why it works like this and what I did wrong.</p>