A 정렬된 데이터 저장소 는 저장된 값이 양의 정수여야 한다는 점을 제외하고 기본적으로 와 동일합니다.정렬된 순서로 항목을 검사할 수 있는 메서드 GetSortedAsync() 를 노출하며, 이 메서드는 DataStorePages 개체를 사용합니다.
정렬된 데이터 저장소는 버전 관리 및 메타데이터를 지원하지 않으므로 DataStoreKeyInfo 는 항상 nil 에 있는 키에 대해 OrderedDataStore입니다.버전 관리 및 메타데이터 지원이 필요한 경우 DataStore를 사용하십시오.
정렬된 데이터 저장소는 userIds 또는 IncrementAsync()에 대한 선택적 SetAsync() 매개 변수를 지원하지 않습니다.
주문형 데이터 저장소 사용에 대한 개요는 데이터 저장소를 참조하십시오.
코드 샘플
This code sample demonstrates usage of an OrderedDataStore and pages.
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()
요약
메서드
- GetSortedAsync(ascending : boolean,pagesize : number,minValue : Variant,maxValue : Variant):DataStorePages
DataStorePages 개체를 반환합니다.
지정된 데이터 저장소의 키 값과 DataStoreKeyInfo 인스턴스를 반환합니다.
- IncrementAsync(key : string,delta : number,userIds : Array,options : DataStoreIncrementOptions):Variant
제공된 금액으로 키의 값을 증가시킵니다(둘 다 정수여야 함).
지정된 키를 제거하면서 액세스 가능한 버전을 유지합니다.
지정된 키에 대한 데이터 저장소 값을 설정합니다.
지정된 콜백 함수에서 새 값으로 키 값을 업데이트합니다.
속성
메서드
GetSortedAsync
DataStorePages 개체를 반환합니다.정렬 순서는 상승순으로 , 각 페이지의 길이는 페이지 크기 , 그리고 minValue / maxValue 는 결과를 필터링하는 선택적 매개 변수입니다.
요청 제한 및 오류 코드 설명은 데이터 저장소를 참조하십시오.
매개 변수
반환된 데이터 페이지가 상승 순서인지를 나타내는 부울입니다.
각 페이지의 길이. 기본값은 50입니다. 최대 허용 값은 100입니다.
선택적 매개 변수. 설정되면 값이 분 이하 인 데이터 페이지가 제외됩니다.
선택적 매개 변수. 설정되면 값이 maxValue 보다 큰 데이터 페이지가 제외됩니다.
반환
제공된 인수에 따라 정렬된 DataStorePages 개체입니다.