if i have the following:
const admin = require('firebase-admin')
const batch = admin.firestore().batch();
const counterRef = admin
.firestore()
.collection(COLLECTIONS.counters)
.doc('daily_counters')
batch.set(counterRef, {
counter_a: admin.firestore.FieldValue.increment(1),
counter_b: admin.firestore.FieldValue.increment(1),
counter_c: admin.firestore.FieldValue.increment(1)
}, { merge: true });
batch.commit();
would the above be counted as 3 writes OR 1 write in terms of billing?
One write, because it writes one document. You don't even need a batch here since it's just one document. An single set/update will have the same effect. The main reason to use a batch is to atomically write multiple documents at the same time, or roll back entirely if anything fails.