CreatorDataStorage

You can use this storage in all the worlds owned by the creator, and it shares the saved data. The Maker and release environment do not share the storage.

# Properties

[{"index":"string Name (ReadOnly)","0":"The name of this CreatorDataStorage."}]

# Methods

[{"index":"int32, List BatchDeleteAndWait(List keys) (ServerOnly) (Yield)","0":"Deletes data with the entered keys. Returns the keys that succeeded in the error code and deletion. Script executions are suspended during the operation."}]

[{"index":"void BatchDeleteAsync(List keys, func> callbackFunction) (ServerOnly)","0":"Deletes data with the entered keys. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the deletion, error code succeeded keys when completing the operation."}]

[{"index":"int32, DataStorageItemPages BatchGetAndWait(List keys) (ServerOnly) (Yield)","0":"Queries data corresponding to the keys entered. Returns the error code and the inquiry entity when the operation is completed. Script executions are suspended during the operation."}]

[{"index":"void BatchGetAsync(List keys, func, DataStorageItemPages> callbackFunction) (ServerOnly)","0":"Queries data corresponding to the keys entered. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, key, and inquiry entity when the operation is complete."}]

[{"index":"int32, DataStorageItemPages BatchGetByInfoAndWait(List keyInfos) (ServerOnly) (Yield)","0":"Queries data with the DataStorageKeyInfo entered. Returns the error code and the inquiry entity when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void BatchGetByInfoAsync(List keyInfos, func, DataStorageItemPages> callbackFunction) (ServerOnly)","0":"Queries data with the DataStorageKeyInfo entered. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, key, and inquiry entity for inquiry when the operation is complete."}]

[{"index":"int32, List BatchSetAndWait(Dictionary keyValues) (ServerOnly) (Yield)","0":"Saves data with the keys entered. Returns the keys that succeeded in the error code and storage. Script executions are suspended during the operation."}]

[{"index":"void BatchSetAsync(Dictionary keyValues, func> callbackFunction) (ServerOnly)","0":"Saves data with the entered keys. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and storage succeeded keys when completing the operation."}]

[{"index":"int32, List BatchSetByInfoAndWait(Dictionary keyValues) (ServerOnly) (Yield)","0":"Saves data with the DataStorageKeyInfo entered. Returns the DataStorageKeyInfo that succeeded in the error code and storage. Script executions are suspended during the operation."}]

[{"index":"void BatchSetByInfoAsync(Dictionary keyValues, func> callbackFunction) (ServerOnly)","0":"Saves data with the entered DataStorageKeyInfo. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and storage succeeded DataStorageKeyInfo when completing the operation."}]

[{"index":"int32 DeleteAndWait(string key) (ServerOnly) (Yield)","0":"Deletes data with the entered key and returns the error code. Script executions are suspended during the operation."}]

[{"index":"void DeleteAsync(string key, func callbackFunction) (ServerOnly)","0":"Deletes data with the entered keys. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and key upon completion of the operation."}]

[{"index":"int32, string GetAndWait(string key) (ServerOnly) (Yield)","0":"Queries data corresponding to the keys entered. Returns the error code and the data when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void GetAsync(string key, func callbackFunction) (ServerOnly)","0":"Queries data corresponding to the keys entered. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, key, and data when the operation is complete."}]

[{"index":"int32, string GetByInfoAndWait(DataStorageKeyInfo keyInfo) (ServerOnly) (Yield)","0":"Queries data with the DataStorageKeyInfo entered. You can set the detailed conditions of data to be loaded with DataStorageKeyInfo. Returns the error code and data when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void GetByInfoAsync(DataStorageKeyInfo keyInfo, func callbackFunction) (ServerOnly)","0":"Queries data with the DataStorageKeyInfo entered. You can set the detailed conditions of data to be loaded with DataStorageKeyInfo. This operation is performed asynchronously. The function passed to the callbackFunction is called with the error code, DataStorageKeyInfo, and data when the operation is complete."}]

[{"index":"int32, DataStorageItemPages GetPagesAndWait(string tag) (ServerOnly) (Yield)","0":"Queries data with the tags entered. Returns the error code and inquiry entity when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void GetPagesAsync(string tag, func callbackFunction) (ServerOnly)","0":"Queries data corresponding to the keys entered. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, tag, and returned entity when the operation is complete."}]

[{"index":"int32, DataStorageVersionPages GetVersionsAndWait(string key, SortDirection sortDirection, DateTime minDate, DateTime maxDate) (ServerOnly) (Yield)","0":"Queries the versions of data corresponding to the keys entered. Displays the inquiry results with the error code and inquiry entity. You can use sortDirection to sort in ascending or descending order. You can query the version created within the time zone set with minDate and maxDate. Suspends script executions during performance."}]

[{"index":"void GetVersionsAsync(string key, SortDirection sortDirection, DateTime minDate, DateTime maxDate, func callbackFunction) (ServerOnly)","0":"Queries the versions of data corresponding to the keys entered. You can use sortDirection to sort in ascending or descending order. You can query the version created within the time zone set with minDate and maxDate. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, key, and inquiry entity when the operation is complete."}]

[{"index":"int32 SetAndWait(string key, string value) (ServerOnly) (Yield)","0":"Saves data with the keys entered. Returns the error code when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void SetAsync(string key, string value, func callbackFunction) (ServerOnly)","0":"Saves data with the keys entered. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and key when the operation is complete."}]

[{"index":"int32 SetByInfoAndWait(DataStorageKeyInfo keyInfo, string value) (ServerOnly) (Yield)","0":"Saves data with the DataStorageKeyInfo entered. You can set the detailed information with DataStorageKeyInfo. Returns the error code when the operation is complete. Script executions are suspended during the operation."}]

[{"index":"void SetByInfoAsync(DataStorageKeyInfo keyInfo, string value, func callbackFunction) (ServerOnly)","0":"Saves data with the DataStorageKeyInfo entered. You can set the detailed information with DataStorageKeyInfo. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and DataStorageKeyInfo when the operation is complete."}]

[{"index":"int32, List TransactDeleteAndWait(List keys) (ServerOnly) (Yield)","0":"Deletes data corresponding to the keys entered. Returns the keys that have been deleted along with the error code if all tasks within the call are successful. Script executions are suspended during operation. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"void TransactDeleteAsync(List keys, func> callbackFunction) (ServerOnly)","0":"Deletes data corresponding to the keys entered. This call is performed asynchronously. The function passed to the callbackFunction is called with the deleted keys and error code if all tasks within the call are successful. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"int32, List TransactSetAndWait(Dictionary keyValues) (ServerOnly) (Yield)","0":"Saves data corresponding to the keys entered. Returns the keys that have been saved along with the error code if all tasks within the call are successful. Script executions are suspended during operation. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"void TransactSetAsync(Dictionary keyValues, func> callbackFunction) (ServerOnly)","0":"Saves data corresponding to the keys entered. This call is performed asynchronously. The function passed to the callbackFunction is called with the saved keys and error code if all tasks within the call are successful. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"int32, List TransactSetByInfoAndWait(Dictionary keyValues) (ServerOnly) (Yield)","0":"Saves data with the entered DataStorageKeyInfo. Returns the DataStorageKeyInfo that succeeded and the error code if all data has been saved. Script executions are suspended during operation. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"void TransactSetByInfoAsync(Dictionary keyValues, func> callbackFunction) (ServerOnly)","0":"Saves data with the DataStorageKeyInfo entered. This call is performed asynchronously. The function passed to the callbackFunction is called with the error code and the saved DataStorageKeyInfo if all tasks within the call are successful. Function will not be called if any of the tasks fail. You can manipulate up to 20 keys at a time."}]

[{"index":"int32, string UpdateAndWait(string key, string expectedValue, string newValue) (ServerOnly) (Yield)","0":"Updates the corresponding key value to newValue. When the operation succeeds, it returns the error code and the updated value. If the previous value and expectedValue are different, it returns the error code UpdateApiFailed(2000000) and the previous value. Suspends script executions during performance."}]

[{"index":"void UpdateAsync(string key, string expectedValue, string newValue, func callbackFunction) (ServerOnly)","0":"Updates the corresponding key value to newValue. This operation is performed asynchronously. The function passed to the callbackFunction is called with the error code, key, and updated value when completing the operation. If the previous value and expectedValue are different, it delivers the error code UpdateApiFailed(2000000), key, and the previous value."}]

[{"index":"int32, string UpdateByInfoAndWait(DataStorageKeyInfo keyInfo, string expectedValue, string newValue) (ServerOnly) (Yield)","0":"Updates the DataStorageKeyInfo value to newValue. When the operation succeeds, it returns the error code and the updated value. If the previous value and expectedValue are different, the error code UpdateApiFailed(2000000) and the previous value are returned. Suspends script executions during performance."}]

[{"index":"void UpdateByInfoAsync(DataStorageKeyInfo keyInfo, string expectedValue, string newValue, func callbackFunction) (ServerOnly)","0":"Updates the DataStorageKeyInfo value to newValue. This operation is performed asynchronously. The function passed to the callbackFunction is called with the error code, DataStorageKeyInfo, and updated value when completing the operation. If the previous value and expectedValue are different, it delivers the error code UpdateApiFailed(2000000), DataStorageKeyInfo, and the previous value."}]

# Examples

#### SetAndWait

This is an example of saving data.
    
    
    @Component
    script DataStorageInitializer extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local errorCode = ds:SetAndWait("key", "value")
            
            if errorCode ~= 0 then
                error("Failed to SetAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### GetAndWait

This is an example of loading data.
    
    
    @Component
    script StartupDataRetriever extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local errorCode, value = ds:GetAndWait("key")
            
            if errorCode ~= 0 then
                error("Failed to GetAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### DeleteAndWait

This is an example of deleting data.
    
    
    @Component
    script GameStartDataDeleter extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local errorCode = ds:DeleteAndWait("key")
            
            if errorCode ~= 0 then
                error("Failed to DeleteAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### SetAsync

This is an example of asynchronously saving data.
    
    
    @Component
    script ServerDataInitializer extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            ds:SetAsync("key", "value", function(errorCode, key)
                -- It will be called when the operation is completed.
                 if errorCode ~= 0 then
                    error("Failed to SetAsync. Error : " .. tostring(errorCode))
                    return
                end
            end)
        end
    end
    

#### GetAsync

This is an example of asynchronously loading data.
    
    
    @Component
    script AsyncKeyValueRetriever extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            ds:GetAsync("key", function(errorCode, key, value)
                -- It will be called when the operation is completed.
                if errorCode ~= 0 then
                    error("Failed to GetAsync. Error : " .. tostring(errorCode))
                    return
                end
            end)
        end
    end
    

#### DeleteAsync

This is an example of asynchronously deleting data.
    
    
    @Component
    script DataStorageKeyDeleter extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            ds:DeleteAsync("key", function(errorCode, key)
                -- It will be called when the operation is completed. 
                if errorCode ~= 0 then
                    error("Failed to DeleteAsync. Error : " .. tostring(errorCode))
                    return
                end
            end)
        end
    end
    

#### SetByInfoAndWait

This is an example of saving data using DataStorageKeyInfo.
    
    
    @Component
    script DataEntryInitializer extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keyInfo = DataStorageKeyInfo("Key", "Version", "Tag")
            local errorCode = ds:SetByInfoAndWait(keyInfo, "Value")
            
            if errorCode ~= 0 then
                error("Failed to SetByInfoAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### GetByInfoAndWait

This is an example of loading data using DataStorageKeyInfo.
    
    
    @Component
    script InitialDataRetriever extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keyInfo = DataStorageKeyInfo("Key", "Version", "Tag")
            local errorCode, value = ds:GetByInfoAndWait(keyInfo)
            
            if errorCode ~= 0 then
                error("Failed to GetByInfoAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### BatchSetAndWait

This is an example of saving data in bulk.
    
    
    @Component
    script ServerDataSetup extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keyValues = {}
            keyValues["Key1"] = "Value1"
            keyValues["Key2"] = "Value2"
            
            local errorCode, keys = ds:BatchSetAndWait(keyValues)
            
            if errorCode ~= 0 then
                error("Failed to BatchSetAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### BatchGetAndWait

This is an example of loading data in bulk.
    
    
    @Component
    script BatchDataFetcher extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keys = {}
            table.insert(keys, "Key1")
            table.insert(keys, "Key2")
            
            local getResultCode, pages = ds:BatchGetAndWait(keys)
            if getResultCode ~= 0 then
                error("Failed to BatchGetAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            while true do
            -- Retrieves the list of items on the current page.
                local datas = pages:GetCurrentPageDatas()
            
                for _, data in pairs(datas) do
                     -- You can inquire the key, version, tag, and value using DataStorageItem.
                    log(data.KeyInfo.Key)
                    log(data.KeyInfo.Version)
                    log(data.KeyInfo.Tag)
                    log(data.Value)
                end
            
                -- Checks if the current page is the last page.
                if pages.IsLastPage == true then
                    break
                end
            
                -- Preloads the data of the next page. If the next page is invalid, stop the inquiry.
                local loadResultCode = pages:LoadNextPageAndWait()
                if loadResultCode ~= 0 then
                    error("Failed to LoadNextPageAndWait. Error : " .. tostring(loadResultCode))
                    break
                end
            
                -- Moves to the next page.
                pages:MoveToNextPageAndWait()
            end
        end
    end
    

#### BatchDeleteAndWait

This is an example of deleting data in bulk.
    
    
    @Component
    script CreatorStorageBatchDeleter extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keys = {}
            table.insert(keys, "Key1")
            table.insert(keys, "Key2")
            
            local errorCode, deletedKeys = ds:BatchDeleteAndWait(keys)
            
            if errorCode ~= 0 then
                error("Failed to BatchDeleteAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### BatchSetByInfoAndWait

This is an example of saving data in bulk using DataStorageKeyInfo.
    
    
    @Component
    script BatchDataSetter extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keyInfoValues = {}
            local keyInfo1 = DataStorageKeyInfo("Key1", "Version1", "Tag1")
            local keyInfo2 = DataStorageKeyInfo("Key2", "Version2", "Tag2")
            
            keyInfoValues[keyInfo1] = "Value1"
            keyInfoValues[keyInfo2] = "Value2"
            
            local errorCode, keyInfos = ds:BatchSetByInfoAndWait(keyInfoValues)
            
            if errorCode ~= 0 then
                error("Failed to BatchSetByInfoAndWait. Error : " .. tostring(errorCode))
                return
            end
        end
    end
    

#### BatchGetByInfoAndWait

This is an example of loading data in bulk using DataStorageKeyInfo.
    
    
    @Component
    script DataStorageBatchRetriever extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local keyInfos = {}
            local keyInfo1 = DataStorageKeyInfo("Key1", "Version1", "Tag1")
            local keyInfo2 = DataStorageKeyInfo("Key2", "Version2", "Tag2")
            table.insert(keyInfos, keyInfo1)
            table.insert(keyInfos, keyInfo2)
            
            local getResultCode, pages = ds:BatchGetByInfoAndWait(keyInfos)
            if getResultCode ~= 0 then
                error("Failed to BatchGetByInfoAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            while true do
            -- Retrieves the list of items on the current page.
                local datas = pages:GetCurrentPageDatas()
                for _, data in pairs(datas) do
                     -- You can inquire the key, version, tag, and value using DataStorageItem.
                    log(data.KeyInfo.Key)
                    log(data.KeyInfo.Version)
                    log(data.KeyInfo.Tag)
                    log(data.Value)
                end
            
                -- Checks if the current page is the last page.
                if pages.IsLastPage == true then
                    break
                end
            
                -- Preloads the data of the next page. If the next page is invalid, stop the inquiry.
                local loadResultCode = pages:LoadNextPageAndWait()
                if loadResultCode ~= 0 then
                    error("Failed to LoadNextPageAndWait. Error : " .. tostring(loadResultCode))
                    break
                end
            
                -- Moves to the next page.
                pages:MoveToNextPageAndWait()
            end
        end
    end
    

#### GetPagesAndWait

This is an example of inquiring data using a tag value.
    
    
    @Component
    script PaginatedDataReader extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local getResultCode, pages = ds:GetPagesAndWait("Tag")
            if getResultCode ~= 0 then
                error("Failed to GetPagesAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            while true do
            -- Retrieves the list of items on the current page.
                local datas = pages:GetCurrentPageDatas()
                for _, data in pairs(datas) do
                     -- You can inquire the key, version, tag, and value using DataStorageItem.
                    log(data.KeyInfo.Key)
                    log(data.KeyInfo.Tag)
                    log(data.KeyInfo.Version)
                    log(data.Value)
                end
            
                -- Checks if the current page is the last page.
                if pages.IsLastPage == true then
                    break
                end
            
                -- Preloads the data of the next page. If the next page is invalid, stop the inquiry.
                local loadResultCode = pages:LoadNextPageAndWait()
                if loadResultCode ~= 0 then
                    error("Failed to LoadNextPageAndWait. Error : " .. tostring(loadResultCode))
                    break
                end
            
                -- Moves to the next page.
                pages:MoveToNextPageAndWait()
            end
        end
    end
    

#### SetByInfoAndWait

This is an example code that utilizes versions.
    
    
    @Component
    script DataVersionUpdate extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local oldKeyInfo = DataStorageKeyInfo("Key", "OldVersion", "Tag")
            local errorCode = ds:SetByInfoAndWait(oldKeyInfo, "OldValue")
            if errorCode ~= 0 then
                error("Failed to SetByInfoAndWait. Error : " .. tostring(errorCode))
                return
            end
            
            -- Instead of overwriting the value of "OldValue" in the existing version, creates a new version and saves it.
            local newKeyInfo = DataStorageKeyInfo("Key", "NewVersion", "Tag")
            errorCode = ds:SetByInfoAndWait(newKeyInfo, "NewValue")
            if errorCode ~= 0 then
                error("Failed to SetByInfoAndWait. Error : " .. tostring(errorCode))
                return
            end
            
            --The value of "OldValue" is still valid as it has not been overwritten. You can specify "OldVersion" to retrieve the value of "OldValue".
            local getResultCode, oldValue = ds:GetByInfoAndWait(oldKeyInfo)
            if getResultCode ~= 0 then
                error("Failed to GetByInfoAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            -- Retrieve the value from a previous version and overwrite it in the latest version. When calling the function to retrieve the subsequent value, the returned value will be "OldValue" instead of "NewValue".
            ds:SetByInfoAndWait(newKeyInfo, oldValue)
        end
    end
    

#### GetVersionsAndWait

This is an example of inquiring version information within a specific time period.
    
    
    @Component
    script DataHistoryViewer extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local minDate = DateTime(2023, 03, 09, 20, 20, 0, 0)
            local maxDate = DateTime(2023, 03, 09, 22, 20, 0, 0)
            
            -- You can only inquire the value if the version value was specified when saving it.
            local getResultCode, pages = ds:GetVersionsAndWait("Key", SortDirection.Ascending, minDate, maxDate)
            if getResultCode ~= 0 then
                error("Failed to GetVersionsAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            while true do
                local datas = pages:GetCurrentPageDatas()
                for _, data in pairs(datas) do
                    -- You can inquire the creation time and version value using DataStorageVersionInfo.
                    log(data.CreateTime)
                    log(data.Version)
                end
            
                -- You can check if the current page is the last page using the IsLastPage property.
                if pages.IsLastPage == true then
                    return
                end
            
                -- Preloads the data of the next page. If the next page is invalid, stop the inquiry.
                local loadResultCode = pages:LoadNextPageAndWait()
                if loadResultCode ~= 0 then
                    error("Failed to LoadNextPageAndWait. Error" .. tostring(loadResultCode))
                    return
                end
            
                -- Moves to the next page.
                pages:MoveToNextPageAndWait()
            end
        end
    end
    

#### UpdateAndWait

This is an example of updating data.
    
    
    @Component
    script OptimisticDataUpdater extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local ds = _DataStorageService:GetCreatorDataStorage()
            
            local getResultCode, oldValue = ds:GetAndWait("Key")
            if getResultCode ~= 0 then
                error("Failed to GetAndWait. Error : " .. tostring(getResultCode))
                return
            end
            
            -- If the expected value is saved in DataStorage, save "NewValue". If a different value is saved, it fails.
            local updateResultCode, newValue = ds:UpdateAndWait("Key", oldValue, "NewValue")
            
            if updateResultCode ~= 0 then
                error("Failed to UpdateAndWait. Error : " .. tostring(updateResultCode))
                return
            end
        end
    end
    

# SeeAlso

  * table
  * DataStorageKeyInfo
  * DateTime
  * DataStorageService