The DataStore class provides access to a persistent data store that can be accessed by scripts from any experience.
public class DataStoreRemarks
All DataStore objects with a given DataStore.Id share the same database.
Members at a glance
| Kind | Members |
|---|---|
| Properties | Id |
| Methods | Delete · Restore · Store |
Properties
Id
public Guid Id { get; }The Id of this DataStore.
Remarks
All DataStore objects with a given DataStore.Id share the same database.
Methods
Delete
public void Delete(
string key,
Action<Sansar.Script.OperationCompleteEvent> done
)Deletes the value associated with the given key
| Parameter | Type | Description |
|---|---|---|
key | string | They key the data is stored under. |
done | Action<Sansar.Script.OperationCompleteEvent> | The action to call when the delete is complete. |
Remarks
Unconditionally deletes the value associated with the given key. For a conditional delete, use DataStore.Delete.
public void Delete<T>(
string key,
DataStore.Options options,
Action<DataStore.Result<T>> done
)Deletes the value associated with the given key
| Parameter | Type | Description |
|---|---|---|
key | string | They key the data is stored under. |
options | DataStore.Options | Controls how the operation proceeds. |
done | Action<DataStore.Result<T>> | The action to call when the delete is complete. |
Type parameters: T: The type of the data stored.
Remarks
Options.Version can be specified to conditionally delete only if the version matches. If the version number does not match, DataStore.Result<T> will have Success == false and the current value in the Version and Object fields.
Restore
public void Restore<T>(string key, Action<DataStore.Result<T>> done)Retrieves the value associated with the given key.
| Parameter | Type | Description |
|---|---|---|
key | string | They key the data is stored under. |
done | Action<DataStore.Result<T>> | The action to call when the restore is complete. |
Type parameters: T: The type of the data stored.
Remarks
If the done action is null, this method will fail without making a call to the data store.
Store
public void Store<T>(
string key,
T value,
Action<DataStore.Result<T>> done
)Serializes the given object to the data store
| Parameter | Type | Description |
|---|---|---|
key | string | The key to store the data under. |
value | T | The object to be converted |
done | Action<DataStore.Result<T>> | The action to call when the store is complete. |
Remarks
The specified key and value will always overwrite any existing data in the store. For a conditional store, use DataStore.Store with Options.Version set to a value from a previous operation.
public void Store<T>(
string key,
T value,
DataStore.Options options,
Action<DataStore.Result<T>> done
)Serializes the given object to the data store
| Parameter | Type | Description |
|---|---|---|
key | string | The key to save the data under. |
value | T | The object to be converted. |
options | DataStore.Options | Controls how the operation proceeds. |
done | Action<DataStore.Result<T>> | The action to call when the conversion is complete. |
Remarks
Options.Version can be specified to conditionally store only if the version matches. If the version number does not match, DataStore.Result<T> will have Success == false and the current value in the Version and Object fields. If Options.RetrieveData false and the write is successful, the response will not include the value written to the store and will simply pass back the value parameter.
Used in examples
Generated from the Sansar 47.10.0 client ScriptApi snapshot.