PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

ListDataStoresAsync

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.

Only data stores containing at least one object will be listed via this function.

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.

int
0

(Optional) Number of items to be returned in each page.

Returns

Return Type Summary

DataStoreListingPages instance containing DataStoreInfo instances that provide details such as name, creation time, and time last updated.


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