Hi everyone!
We shipped a new API today. We can use it to remove keys from DataStore.
Variant GlobalDataStore:RemoveAsync(string key)
param type name: string, the name of the key.
return type:Variant, the old value of the key, if the key didn’t exist, return nil.
This function has throttling limits and the budget share with the “SetAsync”. For the throttling limits, call "RemoveAsync“ will equal to call “SetAsync”.
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
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.
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.
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.
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.