DataStorageService

Provides several DataStorage access functions.

# Methods

[{"index":"int32 DeleteCreatorDataStorageAndWait() (ServerOnly) (Yield)","0":"Deletes CreatorDataStorage and returns the error code. Script executions are suspended during the operation."}]

[{"index":"int32 DeleteCreatorDataStorageAndWait(string name) (ServerOnly) (Yield)","0":"Deletes CreatorDataStorage of a certain name and returns the error code. Script executions are suspended during the operation."}]

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

[{"index":"void DeleteCreatorDataStorageAsync(string name, func callbackFunction) (ServerOnly)","0":"Deletes CreatorDataStorage of a certain name. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and the name of CreatorDataStorage upon completion of the operation."}]

[{"index":"int32 DeleteGlobalDataStorageAndWait(string name) (ServerOnly) (Yield)","0":"Deletes GlobalDataStorage of a certain name and returns the error code. Script executions are suspended during the operation."}]

[{"index":"void DeleteGlobalDataStorageAsync(string name, func callbackFunction) (ServerOnly)","0":"Deletes GlobalDataStorage of a certain name. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and the name of GlobalDataStorage upon completion of the operation."}]

[{"index":"int32 DeleteSortableDataStorageAndWait(string name) (ServerOnly) (Yield)","0":"Deletes SortableDataStorage of a certain name and returns the error code. Script executions are suspended during the operation."}]

[{"index":"void DeleteSortableDataStorageAsync(string name, func callbackFunction) (ServerOnly)","0":"Deletes SortableDataStorage of a certain name. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and the name of SortableDataStorage upon completion of the operation."}]

[{"index":"int32 DeleteUserDataStorageAndWait(string userId) (ServerOnly) (Yield)","0":"Deletes UserDataStorage corresponding to userId and returns the error code. Script executions are suspended during the operation."}]

[{"index":"void DeleteUserDataStorageAsync(string userId, func callbackFunction) (ServerOnly)","0":"Deletes UserDataStorage corresponding to userId. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and userId upon completion of the operation."}]

[{"index":"string GetAndWait(string storageName, string key) (Deprecated) (ServerOnly) (Yield)","0":"This function is deprecated. Please use the GetAndWait() function of each DataStorage."}]

[{"index":"void GetAsync(string storageName, string key, func callbackFunction) (Deprecated) (ServerOnly)","0":"This function is deprecated. Please use the GetAsync() function of each DataStorage."}]

[{"index":"CreatorDataStorage GetCreatorDataStorage() (ServerOnly)","0":"Acquires CreatorDataStorage."}]

[{"index":"CreatorDataStorage GetCreatorDataStorage(string name) (ServerOnly)","0":"Acquires CreatorDataStorage of a certain name."}]

[{"index":"int32, CreatorDataStoragePages GetCreatorDataStoragePagesAndWait() (ServerOnly) (Yield)","0":"Looks up CreatorDataStorage in page units. Returns the error code and inquiry entity when the operation is completed. Script executions are suspended during the operation."}]

[{"index":"void GetCreatorDataStoragePagesAsync(func callbackFunction) (ServerOnly)","0":"Looks up CreatorDataStorage in page units. This operation is performed asynchronously. The function passed to the callbackFunction is called with the error code and the inquiry entity upon completion of the operation."}]

[{"index":"DataStorage GetDataStorage(string name) (Deprecated) (ServerOnly)","0":"This function is now deprecated. Use one of functions from GetGlobalDataStorage(string), GetUserDataStorage(string), GetCreatorDataStorage(), or GetSortableDataStorage(string) for the intended use."}]

[{"index":"GlobalDataStorage GetGlobalDataStorage(string name) (ServerOnly)","0":"Acquires GlobalDataStorage of a certain name."}]

[{"index":"int32, GlobalDataStoragePages GetGlobalDataStoragePagesAndWait() (ServerOnly) (Yield)","0":"Inquires about GlobalDataStorage in page units. You can see the inquiry result with the returned entity. The script executions are suspended during performing."}]

[{"index":"void GetGlobalDataStoragePagesAsync(func callbackFunction) (ServerOnly)","0":"Looks up GlobalDataStorage in page units. You can see the inquiry result with the returned entity. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code and entity for inquiry when completing the operation."}]

[{"index":"SortableDataStorage GetSortableDataStorage(string name) (ServerOnly)","0":"Acquires SortableDataStorage of a certain name."}]

[{"index":"int32, SortableDataStoragePages GetSortableDataStoragePagesAndWait() (ServerOnly) (Yield)","0":"Looks up SortableDataStorage in page units. Returns the error code and inquiry entity when the operation is completed. Script executions are suspended during the operation."}]

[{"index":"void GetSortableDataStoragePagesAsync(func callbackFunction) (ServerOnly)","0":"Inquires about SortableDataStorage in page units. This operation is performed asynchronously, and the function passed to the callbackFunction is called with the error code, entity for inquiry when completing the operation."}]

[{"index":"UserDataStorage GetUserDataStorage(string userId) (ServerOnly)","0":"Acquires UserDataStorage for certain users."}]

[{"index":"int32, UserDataStoragePages GetUserDataStoragePagesAndWait() (ServerOnly) (Yield)","0":"Looks up UserDataStorage in page units. Returns the error code and inquiry entity when the operation is completed. Script executions are suspended during the operation."}]

[{"index":"void GetUserDataStoragePagesAsync(func callbackFunction) (ServerOnly)","0":"Looks up UserDataStorage in page units. This operation is performed asynchronously. The function passed to the callbackFunction is called with the error code and the inquiry entity upon completion of the operation."}]

[{"index":"boolean SetAndWait(string storageName, string key, string value) (Deprecated) (ServerOnly) (Yield)","0":"This function is deprecated. Please use the SetAndWait() function of DataStorage for its purpose."}]

[{"index":"void SetAsync(string storageName, string key, string value, func callbackFunction) (Deprecated) (ServerOnly)","0":"This function is deprecated. Please use the SetAsync() function of DataStorage for its purpose."}]

##### inherited from Service:

[{"index":"EventHandlerBase ConnectEvent(string key, IScriptFunction eventHandler)","0":"Links events. When a key-type event occurs in this service, a handler is notified. The handler receives event parameters."}]

[{"index":"EventHandlerBase ConnectEvent(Type eventType, IScriptFunction eventHandler)","0":"Links events. This service notifies a handler when an eventType event occurs. The handler receives event parameters."}]

[{"index":"boolean DisconnectEvent(string key, EventHandlerBase eventHandler)","0":"Disconnects the event with the key-type event and the handler."}]

[{"index":"boolean DisconnectEvent(Type eventType, EventHandlerBase eventHandler)","0":"Disconnects the eventType event from its handler."}]

[{"index":"void SendEvent(EventType sendEvent)","0":"Generates an event."}]

# Examples

#### GetGlobalDataStorage

The following is an example of importing GlobalDataStorage using DataStorageService.
    
    
    @Component
    script GlobalStorageInitializer extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            local sampleStorage = _DataStorageService:GetGlobalDataStorage("sampleStorage")
        end
    end
    

#### GetGlobalDataStoragePagesAsync

The following is an example of removing all GlobalDataStorage using DataStorageService.
    
    
    @Component
    script GlobalDataPurger extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            _DataStorageService:GetGlobalDataStoragePagesAsync(function(errorCode, pages)
            if errorCode ~= 0 then
            	return
            end
            
            while true do
            	local dataStorages = pages:GetCurrentPageDatas()
            
            	for i, dataStorage in ipairs(dataStorages) do
            		_DataStorageService:DeleteGlobalDataStorageAndWait(dataStorage.Name)
            	end
            
            	if pages.IsLastPage == true then
            		break
            	end
            
            	pages:MoveToNextPageAndWait()
            	end
            end)
        end
    end
    

# SeeAlso

  * DataStorageItem
  * DataStorageItemPages
  * DataStorageKeyInfo
  * DataStorageVersionPages
  * DateTime
  * GlobalDataStorage
  * GlobalDataStoragePages
  * SortableDataStorage
  * SortableDataStorageItem
  * SortableDataStorageItemPages
  * SortableDataStoragePages
  * UserDataStorage
  * UserDataStoragePages
  * [Saving and Importing Data DB](/docs?postId=68)
  * [Utilizing DataStorage](/docs?postId=692)