Firebase-js-sdk: FR: firebase.firestore.FieldValue.increment(value)

Created on 10 Jan 2019  路  3Comments  路  Source: firebase/firebase-js-sdk


[REQUIRED] Describe your environment

  • Operating System version: all
  • Browser version: _____
  • Firebase SDK version: 5.7.1
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Similar to
firebase.firestore.FieldValue.arrayUnion(value)
firebase.firestore.FieldValue.arrayRemove(value)

would be great if we have option appendValue(n)
where use it only for numbers fields and (n) should be number even positive or negative value.
this will enable us to minimize the number of transactions for counters problem. and even help us to do counter operations on offline mode..

Code Example

  var doc = { a:5, b:10};

 var n = -1; //any number 

 var changeCounter = {a : firebase.firestore.FieldValue.appendValue(n)};

 firestore.collection('col').document('doc').update(changeCounter);

 newDocResult = {a:4, b:10};

Thanks for amazing firestore

firestore

Most helpful comment

1368 has been merged and will be released in the next release.

All 3 comments

As always, I can't promise timelines but this is coming soon. See https://github.com/firebase/firebase-js-sdk/pull/1368.

It will be firebase.firestore.FieldValue.increment.

amazing...
usually i follow every pull request, i miss this one..
Thanks

1368 has been merged and will be released in the next release.

Was this page helpful?
0 / 5 - 0 ratings