OrderedDataStore

显示已弃用

*此内容使用人工智能(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

一个 bool 指示返回的数据页是否按升序排列。

默认值:""
pagesize: number

每页的长度。默认值为 50。最大允许值为 100。

默认值:""
minValue: Variant

可选参数。如果设置,数据页面的值小于 minValue 将被排除。

默认值:""
maxValue: Variant

可选参数。如果设置,数据页面的值大于 maxValue 将被排除。

默认值:""

返回

按提供的参数排序的 DataStorePages 对象。

活动