OrderedDataStore

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

無法建立
未複製

一個 排序資料儲存器 本質上是一個 GlobalDataStore ,除了儲存值必須是 正整數 之外。它暴露了一個方法 GetSortedAsync() ,可以使用 DataStorePages 對象檢查排序的物件入進行檢查。

排序的數據儲存不支持版本和元數據,因此 DataStoreKeyInfo 永遠是 nil 對於 OrderedDataStore 中的鑰匙。如需版本控制和元數據協助,請使用 DataStore

排序的資料儲存不支持 userIdsSetAsync()IncrementAsync() 的可選參數。

請參閱數據儲存以獲得使用訂閱數據儲存的概觀。

範例程式碼

This code sample demonstrates usage of an OrderedDataStore and pages.

OrderedDataStore Basics

local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetOrderedDataStore("Points")
local function printTopTenPlayers()
local isAscending = false
local pageSize = 10
local pages = pointsStore:GetSortedAsync(isAscending, pageSize)
local topTen = pages:GetCurrentPage()
-- The data in 'topTen' is stored with the index being the index on the page
-- For each item, 'data.key' is the key in the OrderedDataStore and 'data.value' is the value
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(name .. " is ranked #" .. rank .. " with " .. points .. "points")
end
-- Potentially load the next page...
--pages:AdvanceToNextPageAsync()
end
-- Create some data
pointsStore:SetAsync("Alex", 55)
pointsStore:SetAsync("Charley", 32)
pointsStore:SetAsync("Sydney", 68)
-- Display the top ten players
printTopTenPlayers()

概要

方法

方法 繼承自 GlobalDataStore

屬性

方法

GetSortedAsync

暫停

返回 DataStorePages 個對象。排序順序由 上升 決定,每頁長度由 頁面尺寸 決定,而 minValue / maxValue 是可選參數,用於過濾結果。

請參閱數據儲存以獲得請求限制和錯誤代碼說明。

參數

ascending: boolean

一個是否指示返回的數據頁是否排序上升的 boolean 值。

預設值:""
pagesize: number

每頁的長度。預設值為 50。最大允許值為 100。

預設值:""
minValue: Variant

可選參數。如果設定,數值小於 minValue 的數據頁將被排除。

預設值:""
maxValue: Variant

可選參數。如果設定,數值大於 maxValue 的數據頁將被排除。

預設值:""

返回

根據提供的參數排序的 DataStorePages 對象。

活動