Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore Increment FieldValue

So, I know there are a few similarly named questions, but this is not the same. I am curious to see if anyone could explain the reasoning for the lack of an increment sentinel, similar to the delete one.

As far as I know, a field deletion is no different than a document update. Meaning, I can just delete my field by simply updating the entire document to some new data, leaving that field out, hence, the question.

If we have a FieldValue.delete(), why the lack of a FieldValue.increment()

Note: I am aware of the 1QPS limit and I doubt it has anything to do with the above.

Regards!

like image 635
Eduard Avatar asked Feb 05 '19 21:02

Eduard


1 Answers

Version 5.9.0 - Mar 14, 2019

Added FieldValue.increment(), which can be used in update() and set(..., {merge:true}) to increment or decrement numeric field values safely without transactions.

https://firebase.google.com/support/release-notes/js

like image 80
Henry Avatar answered Sep 18 '22 11:09

Henry