Skip to main content

SaveSlotSharedDataStoreService

This item only works when running on the server. Server

Owns a single global (non-player) datastore that hands save-slot snapshots between sessions and players. Unlike a player store this is a flat key/value store -- each key (a code/guid) holds one snapshot -- with no session locking, so a write is immediately loadable from any server. Pair it with HasSaveSlots.PromiseSaveSlotToSharedDataStore / HasSaveSlots.PromiseImportSlotFromSharedDataStore.

Functions

SetRobloxDataStore

SaveSlotSharedDataStoreService.SetRobloxDataStore() → ()

Injects the underlying datastore to use instead of resolving a real one. Accepts a real datastore or a DataStoreMock. Intended for testing; must be called before the datastore is first resolved.

SetDataStoreName

SaveSlotSharedDataStoreService.SetDataStoreName(
namestring
) → ()

Sets the datastore name. Must be called before the datastore is first resolved.

SetDataStoreScope

SaveSlotSharedDataStoreService.SetDataStoreScope(
scopestring
) → ()

Sets the datastore scope. Must be called before the datastore is first resolved.

PromiseWrite

SaveSlotSharedDataStoreService.PromiseWrite(
keystring,
valueany,
userIds{number}?
) → Promise<boolean>

Writes a value under the given key, optionally tagging the owning user ids (for data-erasure discoverability). Resolves once the write commits.

PromiseRead

SaveSlotSharedDataStoreService.PromiseRead(
keystring
) → Promise<any>

Reads the value stored under the given key, resolving nil when absent.

PromiseRemove

SaveSlotSharedDataStoreService.PromiseRemove(
keystring
) → Promise<boolean>

Removes the value stored under the given key.

Show raw api
{
    "functions": [
        {
            "name": "SetRobloxDataStore",
            "desc": "Injects the underlying datastore to use instead of resolving a real one. Accepts a real datastore\nor a [DataStoreMock]. Intended for testing; must be called before the datastore is first resolved.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "robloxDataStore",
                    "desc": "",
                    "lua_type": "DataStore | DataStoreMock"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 51,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        },
        {
            "name": "SetDataStoreName",
            "desc": "Sets the datastore name. Must be called before the datastore is first resolved.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 64,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        },
        {
            "name": "SetDataStoreScope",
            "desc": "Sets the datastore scope. Must be called before the datastore is first resolved.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "scope",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 74,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        },
        {
            "name": "PromiseWrite",
            "desc": "Writes a value under the given key, optionally tagging the owning user ids (for data-erasure\ndiscoverability). Resolves once the write commits.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "userIds",
                    "desc": "",
                    "lua_type": "{ number }?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 90,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        },
        {
            "name": "PromiseRead",
            "desc": "Reads the value stored under the given key, resolving nil when absent.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<any>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 109,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        },
        {
            "name": "PromiseRemove",
            "desc": "Removes the value stored under the given key.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "SaveSlotSharedDataStoreService",
    "desc": "Owns a single global (non-player) datastore that hands save-slot snapshots between sessions and\nplayers. Unlike a player store this is a flat key/value store -- each key (a code/guid) holds one\nsnapshot -- with no session locking, so a write is immediately loadable from any server. Pair it\nwith [HasSaveSlots.PromiseSaveSlotToSharedDataStore] / [HasSaveSlots.PromiseImportSlotFromSharedDataStore].",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 11,
        "path": "src/saveslot/src/Server/SaveSlotSharedDataStoreService.lua"
    }
}