so what im trying to do is store a lot (i mean thousands to millions) of pieces of data without exhausting my datastore. Lets take this hypothetical situation here:
local Table = {
"1",
"2",
"3",
--etc etc
}
for i, v in pairs(Table) do
dataStore:UpdateAsync("ds", function(ov)
ov[i] = v
return ov
end)
end
my knowledge is pretty small on this, as I haven’t messed with updateasync so much so correct me if I’m wrong. But anyways im trying to store a lot of data all at once with out updating it multiple times (exhaust) i know you may be asking why not just save the whole table. For the thing I’m doing that’s not possible.
Just an idea, but maybe combine all the data into a single string and put a space between each piece of data then when loading the data you could split it / convert it back.
Datastores are primarily meant for storing single-user data, and occasionally for some unique instances, single-server data. For that reason if you want to store millions of pieces of data, you might consider using a database hosted on an online service such as google cloud for something like this. If you still want to use a database, though, here’s what I recommend:
Create a table with index:value pairs for whatever updates you need. So for instance:
Then call update async once and set ov[index] = key for all updates in the table. So it’d look something like:
dataStore:UpdateAsync("ds", function(ov)
for i,v in pairs(updates) do
ov[i] = v
end
return ov
end)
This way you only have to use one datastore call, and it handles all the updates you need.
Side note: I know you’re not doing this, but make sure you don’t use ipairs for this, and instead use pairs. Because of the way we set this up, it treats the index numbers like a Map/Dictionary, not an Array.
i had tried this once this exact thing but it didn’t seem to work as far as i saw cause i thought it would exhaust the data store. so i decided to re-asses this. i’ll check it out when i get on my pc.
alright this works! thank you. It turns out the issue I had was that the return ov was inside the loop causing it not to work. Much appreciated. UpdateAsync() was something I never really got to fully learn so this is a great lesson on understanding it better. Thank you!