Bulk update OrderedDataStore

Currently, with datastores, we can’t use UpdateAsync to bulk update the table’s data as it requires you to update each data of the table separately.

taking the example code from the devhub

local DataStoreService = game:GetService("DataStoreService")
local PointsODS = DataStoreService:GetOrderedDataStore("Points") 

PointsODS:SetAsync("Alex", 55)
PointsODS:SetAsync("Charley", 32)
PointsODS:SetAsync("Sydney", 68)

That is 1 request per player… which is rather inefficient.

if we were able to do something along the line of:

local LeaderboardCache = {
    ["Alex"] = 55,
    ["Charley"] = 32,
    ["Sydney"] = 68
}

PointsODS:UpdateBulk(function(oldTable)
    for User, Score in pairs(LeaderboardCache) do
         oldTable[User] = Score
    end
    return oldTable
end)

This is one request, that updates multiple players in one go, which can significantly save up datastore requests for you to use on other things.

11 Likes

Vouch, but I would like this for normal datastores aswell, would be incredibly useful