DataStore

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้จะพร้อมใช้งานในภาษาที่คุณเลือกในเร็วๆ นี้

ไม่สามารถสร้าง
ไม่ซ้ำ

สรุป

วิธีการ

วิธีการรับทอดมาจากGlobalDataStore

คุณสมบัติ

วิธีการ

GetVersionAsync

ผลตอบแทน

This function retrieves the specified key version as well as a DataStoreKeyInfo instance. A version identifier can be found through DataStore:ListVersionsAsync() or alternatively be the identifier returned by GlobalDataStore:SetAsync().

พารามิเตอร์

key: string

Key name for which the version info is requested. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".

version: string

Version number of the key for which the version info is requested.


ส่งค่ากลับ

The value of the key at the specified version and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata.

ListKeysAsync

ผลตอบแทน

This function returns a DataStoreKeyPages object for enumerating through keys of a data store. It accepts an optional prefix parameter to only locate keys whose names start with the provided prefix.

If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), keys will be returned with all scopes as prefixes.

พารามิเตอร์

prefix: string

(Optional) Prefix to use for locating keys.

ค่าเริ่มต้น: ""
pageSize: number

(Optional) Maximum possible number of items that can be returned.

ค่าเริ่มต้น: 0
cursor: string

(Optional) Cursor to continue iteration.

ค่าเริ่มต้น: ""
excludeDeleted: bool

(Optional) Exclude deleted keys from being returned.

When enabled ListKeys will check up to 512 keys. If all checked keys are deleted then it will return an empty list with a cursor to continue iteration.

ค่าเริ่มต้น: false

ส่งค่ากลับ

A DataStoreKeyPages instance that enumerates the keys as DataStoreKey instances.

ListVersionsAsync

ผลตอบแทน

This function enumerates versions of the specified key in either ascending or descending order specified by a Enum.SortDirection parameter. It can optionally filter the returned versions by minimum and maximum timestamp.

พารามิเตอร์

key: string

Key name for the versions to list. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".

sortDirection: Enum.SortDirection

Enum specifying ascending or descending sort order.

ค่าเริ่มต้น: "Ascending"
minDate: number

Unix timestamp in milliseconds after which the versions should be listed.

ค่าเริ่มต้น: 0
maxDate: number

Unix timestamp in milliseconds up to which the versions should be listed.

ค่าเริ่มต้น: 0
pageSize: number

Number of items to be returned in each page.

ค่าเริ่มต้น: 0

ส่งค่ากลับ

A DataStoreVersionPages instance that enumerates all the versions of the key as DataStoreObjectVersionInfo instances.

ตัวอย่างโค้ด

Retrieving DataStore Versions With A Date Filter

local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local time = DateTime.fromUniversalTime(2020, 10, 09, 01, 42)
local listSuccess, pages = pcall(function()
return experienceStore:ListVersionsAsync("User_1234", nil, time.UnixTimestampMillis)
end)
if listSuccess then
local items = pages:GetCurrentPage()
for key, info in pairs(items) do
print("Key:", key, "; Version:", info.Version, "; Created:", info.CreatedTime, "; Deleted:", info.IsDeleted)
end
end

RemoveVersionAsync

void
ผลตอบแทน

This function permanently deletes the specified version of a key. Version identifiers can be found through DataStore:ListVersionsAsync().

Unlike GlobalDataStore:RemoveAsync(), this function does not create a new "tombstone" version and the removed value cannot be retrieved later.

พารามิเตอร์

key: string

Key name for which a version is to be removed. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".

version: string

Version number of the key to remove.


ส่งค่ากลับ

void

อีเวนต์