Increment value inside Firestore using a batch - "Ambiguous use of 'increment'"

Viewed 652

I simply would like to increment a value inside my Cloud-Firestore but I can not get it done and can't find any solutions in the docs..

This is what I tried:

let batch = db.batch()

// Set username and uid for user
let userRef = Firestore.firestore().collection("users").document(userID)

batch.updateData(["population": FieldValue.increment(1)], forDocument: userRef)

But this gives me this error:

Ambiguous use of 'increment'

What's the right way to get this done? Is this actually possible with batch?

Update: The reason I would like to use batch is that inside the function I need to update some other fields as well.

1 Answers
Related