ListDataStoresAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
For thread safety, this property is not safe to read in an unsynchronized thread.
Returns a DataStoreListingPages object for enumerating through all of the experience’s data stores. It accepts an optional prefix parameter to only locate data stores whose names start with the provided prefix.
See Also
Articles/Data store|Data Stores, an in-depth guide on data structure, management, error handling, etc.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
(Optional) Prefix to enumerate data stores that start with the given prefix. |
||
|
0
|
(Optional) Number of items to be returned in each page. |
Returns
| Return Type | Summary |
|---|---|
|
|
Code Samples
List Data Stores by Prefix
The following code sample lists all data stores starting with the prefix house, using DataStoreService/ListDataStoresAsync to retrieve a list of pages and a while loop to look through all pages until Pages/IsFinished indicates the list’s end.
local DataStoreService = game:GetService("DataStoreService")
local listSuccess, pages = pcall(function()
return DataStoreService:ListDataStoresAsync("house")
end)
if listSuccess then
while true do
local items = pages:GetCurrentPage()
for _, ds in ipairs(items) do
print(ds.DataStoreName, "| Created:", ds.CreatedTime)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
end