Datastore, get all values

This is for a side project, but I was wondering if it is possible to get all the keys of the datastore (the key you use in get async).

1 Like

Please can you explain your question a bit more? The way you’ve explained it is very lackluster: what do you actually want to do? Have you tried anything before posting this? What are you using it for?

Please tell me the answers to these questions as right now I and others can’t really help.

2 Likes

Sorry, I don’t know much of the terms. I’ll explain in here.

DataStore:GetAsync("ok" -- this is what i meant by the key)

So, is there a way to get an array of all the keys?

No. There is no way to get a list of all keys in a DataStore, aside from using an OrderedDataStore’s GetSortedAsync (but that only returns a limited number of results based on specific criteria).

OrderedDataStores can only save numbers. You can learn about them here

3 Likes

This is still pretty bare, however I believe what you’re trying to say is you’d like to fetch everything in the dataStore, correct?

Well, if so, theres 2 ways to do this. The first way is to save the data externally, in a data cache, or something, where everything is already in an array if you set it up correctly. This’ll work better for large scale games, which is pretty good. However, the second way (and less supported way) is by using orderedDataStores.

1 Like

That is correct (I’m sorry, I am the worst at explaining things). Thanks for the clear up, I was planning on making a game management system and was wondering if I could make all the data visible to the owner.

With a data cache, that is somewhat viable as it’d be saved externally, allowing for it to be viewed externally. Unfortunately, however, you may have to pay for a service to host your database, unless you’d prefer to host it yourself, or use something like trello (which I do recommend).

However, if you’d prefer to actually see it in game, I believe you can export data to something like your sql table or, as I said, trello. Once you’ve exported it, you can import it and then re-arrange it, however that may be a bit straining, but I’m not very good with webhooks and exporting data so don’t quote me on it.

Trello is not a database. Do not use it as such.

Webhooks are also not databases; webhooks are similar to one-way events.

3 Likes

There is technically a way.
You would have to assign numbers as the players name and have a store keeping count of the number of datastore entrys.

I have done it.
https://pastebin.com/jy5rw8UJ

In the script I have got ‘CreateListing’, ‘GetListings’ and ‘RemoveListing’
There is of course room for improvement but its proof that it is possible, however it does mean that if you want to know whos data it is you will have to add it into the data that is stored.

If you still need to link the information to the player you can create another store that stores the EntryNumber of the player and then use the EntryNumber to access the information.

3 Likes