Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's the best way to organize a datastore?

Asked by 5 years ago
Edited 5 years ago
01pages = AdHistoryKeys:GetSortedAsync(false, 100)
02pagesTable = {}
03pcall(function()
04    while wait() do
05        local currentTable = {}
06        print("1: "..#pages:GetCurrentPage())
07        for _,v in pairs(pages:GetCurrentPage()) do
08                local value = AdHistory:GetAsync(v.key) -- problem here
09            table.insert(currentTable,#currentTable+1,value)
10        end
11        table.insert(pagesTable, currentTable)
12        pages:AdvanceToNextPageAsync()
13    end
14end)
15for _,page in pairs(pagesTable) do
16    print(#page)
17    for _,v in pairs(page) do
18        print("2: "..v) -- prints only one value from the current page
19    end
20end

First: AdHistoryKeys is a OrderedDataStore with a key for AdHistory (a regular DataStore), and the value being a timestamp, so I can sort by the last created.

my problem lies in AdHistory:GetAsync(v.key) I found that if I replace that with a normal table, it will work fine. I've figured out that it's because of datastore limits. How I was planning on fixing this was just having a single key with a dictionary for the value, but I'm not sure if that's the best way. My only fear would be it could easily corrupt all data inside the table.

0
That's not what I'm trying to do, I have to store the keys of a regular dataStore inside of an orderedDataStore. The problem is that I can't get all the values of the dataStore as it limits the amount of GetAsync calls you can make. Internal_1 344 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I have decided to store all data inside a single key in the regular datastore, and have the value be a giant dictionary. I will then store all the indexes to the dictionary inside of the orderdatastore, being sorted by a timestamp. I will edit this when I am done.

Ad

Answer this question