Class
DataStore
NotCreatableNotReplicated
A GlobalDataStore that also supports versioning, key metadata, and
enumerating keys.
See Data stores for an in-depth guide on data structure, management, error handling, limits, and more.
Methods 5#
| GetVersionAsync | Retrieves the specified key version.Yields |
| GetVersionAtTimeAsync | Retrieves the key version that was current at a given time.Yields |
| ListKeysAsync | Returns a DataStoreKeyPages object for enumerating through keys of
a data store.Yields |
| ListVersionsAsync | Enumerates all versions of a key.Yields |
| RemoveVersionAsync | Permanently deletes the specified version of a key.DeprecatedYields |
GetVersionAsync(key: string, version: string): Tuple#
Yields
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().
| Name | Type | Default | Description |
|---|---|---|---|
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. |
Returns
Tuple— The value of the key at the specified version and aDataStoreKeyInfoinstance that includes the version number, date and time the version was created, and functions to retrieveUserIdsand metadata.
GetVersionAtTimeAsync(key: string, timestamp: int64): Tuple#
Yields
This function retrieves the key version that was current at a given time
as well as a DataStoreKeyInfo instance.
| Name | Type | Default | Description |
|---|---|---|---|
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". | |
timestamp | int64 | Unix timestamp in milliseconds for which the requested version was current. Must be greater than zero. Must not be more than ten minutes in the future. |
Returns
Tuple— The value of the key that was current at the specified time and aDataStoreKeyInfoinstance that includes the version number, date and time the version was created, and functions to retrieveUserIdsand metadata.nilif no available version was current at the requested time.
ListKeysAsync(prefix: string, pageSize: int = 0, cursor: string, excludeDeleted: boolean = false): DataStoreKeyPages#
Yields
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.
| Name | Type | Default | Description |
|---|---|---|---|
prefix | string | (Optional) Prefix to use for locating keys. | |
pageSize | int | 0 | (Optional) Number of items to be returned in each page. If no value is given, the engine sends a default value of 0 to the data store web service, which in turn defaults to 50 items per page. |
cursor | string | (Optional) Cursor to continue iteration. | |
excludeDeleted | boolean | false | (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. |
Returns
DataStoreKeyPages— ADataStoreKeyPagesinstance that enumerates the keys asDataStoreKeyinstances.
ListVersionsAsync(key: string, sortDirection: SortDirection = Ascending, minDate: int64 = 0, maxDate: int64 = 0, pageSize: int = 0): DataStoreVersionPages#
Yields
This function enumerates versions of the specified key in either ascending
or descending order specified by a SortDirection parameter. It can
optionally filter the returned versions by minimum and maximum timestamp.
| Name | Type | Default | Description |
|---|---|---|---|
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 | SortDirection | Ascending | (Optional) Enum specifying ascending or descending sort order. |
minDate | int64 | 0 | (Optional) Unix timestamp in milliseconds after which the versions should be listed. |
maxDate | int64 | 0 | (Optional) Unix timestamp in milliseconds up to which the versions should be listed. |
pageSize | int | 0 | (Optional) Number of items to be returned in each page. If no value is given, the engine sends a default value of 0 to the data store web service, which in turn defaults to 1024 items per page. |
Returns
DataStoreVersionPages— ADataStoreVersionPagesinstance that enumerates all the versions of the key asDataStoreObjectVersionInfoinstances.
RemoveVersionAsync(key: string, version: string): ()#
YieldsDeprecatedDeprecated
Deprecated. This method is deprecated. Do not use it for new work.
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.
| Name | Type | Default | Description |
|---|---|---|---|
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. |
Returns
()
Inherited members#
Inherited from GlobalDataStore 7
Methods (7)
BatchGetAsync, GetAsync, IncrementAsync, OnUpdate, RemoveAsync, SetAsync, UpdateAsync
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild