Home > Net >  Writing my own atomic increment for Firebase RTDB Unity SDK okay?
Writing my own atomic increment for Firebase RTDB Unity SDK okay?

Time:08-16

So it seems that the RTDB sdk for Unity is missing the atomic increment function that is available in the other SDKs..

this guy -> database.ServerValue.increment(1);

I've noticed all that it is doing is setting the database reference to this object

{
  '.sv': { 
    increment: 5 
  }
}

I have tested setting this object manually myself as the value for the database reference.. and it works as expected!

My question is..

Is that okay to do? Will that possibly break in the future while i have my app live? Or will i have time to update it to something new if they DO change it?

CodePudding user response:

Yup, writing the sentinel value yourself is fine. We can't guarantee it won't ever break, but the specific value is actually documented for the REST API - so it'd require a major version upgrade if that were to ever change.

There is an open feature request #649 to add it to the SDK, so I'd recommend also chiming in there.

  • Related