So when it comes to datastores and saving stuff all the data is saved on a list
So basically I was wondering if when you use:
datastore:SetAsync(data)
is what I just saved at the bottom of the list of data in said datastore?
Cause I want to make it so I have a function so when you trigger it it gets the newest data saved to the datastore, when I really think about it I doubt thats how it works and it that is true how can I make it so I have a function so when you trigger it it gets the newest data saved to the datastore?
in your case, you could just use some sort of UTC timestamp as the key or provide it in the dataset itself.
as a pseudo example, i would probably do something like this but there could also be easier ways depending on the context… also dont forget to utilize things like pcall.
--server script, don't copy and paste.
local function getTimestamp()
return os.date("!%Y-%m-%dT%H:%M:%SZ")
end
local masterKey = "myKey"
local data = DS:GetAsync(masterKey)
data[getTimestamp()] = "blah"
DS:SetASync(masterKey, data)
and then you can easily go through “data” to see which entry inside is the latest one.
So from the look of it(And actually using it).
Using GetOrdedDatastore() doesnt allow me to loop through the items it just gets the datastore in order and I am still unable to loop through the items with out using :GetSortedAsync(). At least thats what I can tell from the document
Hmm do you know of a way to loop through regular datastores asyncs? I need to loop through the data with out using an OrderedDatastore cause they can only save numbers
You don’t loop through them, you use :GetAsync() and :SetAsync() with a key, usually the player’s userid. Please make a new post if you are stuck, also read up on the datastore’s documentation.
Yes I know but I need to well get them and basically loop through them as GetOrderedAsync works. Not that I think about it I can just save there titles to a datastore table and then loop through that