New API GlobalDataStore:RemoveAsync(string key)

Hi everyone!
We shipped a new API today. We can use it to remove keys from DataStore.

Variant GlobalDataStore:RemoveAsync(string key)

  1. param type name: string, the name of the key.
  2. return type:Variant, the old value of the key, if the key didn’t exist, return nil.
  3. This function has throttling limits and the budget share with the “SetAsync”. For the throttling limits, call "RemoveAsync“ will equal to call “SetAsync”.
  4. If there is a connection bind to the ‘key’, the OnUpdate callback will be invoked with a nil value after the ”key" have been removed.

Warnning: We found a bug about this API. RemoveAsync should return a “Variant” but return a string which is serialized from the “Variant”. We will fix this ASAP. 10/26/2017
The bug “RemoveAsync return a string which is serialized from the “Variant”” already fixed. 11/8/2017

61 Likes

Awh yeah that’s the good stuff.

Woohoo. I like that the method returns the value previously saved at the key; that is good attention to detail.

17 Likes

Cool!

Satisfaction…

1 Like

Is there any benefit to using this over setting it to nil?

2 Likes

You can’t set a Datastore key with nil, otherwise it’ll error.

2 Likes

Setting a key to nil wouldn’t necessarily communicate deletion, since it’s common for data sets to allow a null value. So the key still exists with a value, but the value is null. Thus you will always see a remove/delete method on APIs accessing databases of any sort.

But of course, as @davness said, we can’t even set a key to have a nil value. Thus we just treat non-existing keys as nil values.

6 Likes

Excellent! This eases up workload for a few things on my part since I allow users to delete certain saved avatar outfits in my game. Beforhand, I had to set the save data to a blank value. This is much better, since I can actually get rid of the data.

2 Likes

THANK YOU!

I’ve been waiting for this API since 2015. :slight_smile:

1 Like

Sweet thanks!

Hi everyone, we found a bug about this API. RemoveAsync should return a “Variant” but return a string which is serialized from the “Variant”. We will fix this ASAP.

3 Likes

Great! If nothing else it may save a bit of space on the Roblox servers. It’s great to have a more official way to delete data vs writing over the old values.

Keep it up Roblox! We’re headed in the right direction.

1 Like

The bug “RemoveAsync return a string which is serialized from the “Variant”” already fixed. 11/8/2017

4 Likes