Skip to main content

Collection

Collections are analagous to GlobalDataStore.

Functions

load

Collection:load(
keystring,
defaultUserIds{number}?
) → Promise<Document>

Loads the document with key, migrates it, and session locks it.

If specified, the document's DataStoreKeyInfo:GetUserIds() will be set to defaultUserIds if the document has never been loaded.

read

Collection:read(keystring) → Promise<T?>

Reads the data of the document with key regardless of whether it is session locked. This is useful for viewing a document without editing or session locking it. The data gets migrated but not saved.

If the document has never been loaded, the promise will return nil.

DataStoreGetOptions.UseCache is disabled.

remove

Collection:remove(keystring) → Promise<()>

Removes the data of the document with key.

If a document is open while remove is called, the open document will fail to save/close and the data will still be removed.

Show raw api
{
    "functions": [
        {
            "name": "load",
            "desc": "Loads the document with `key`, migrates it, and session locks it.\n\nIf specified, the document's `DataStoreKeyInfo:GetUserIds()` will be set to `defaultUserIds` if the document has\nnever been loaded.",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "defaultUserIds",
                    "desc": "",
                    "lua_type": "{number}?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<Document>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 59,
                "path": "src/Collection.luau"
            }
        },
        {
            "name": "read",
            "desc": "Reads the data of the document with `key` regardless of whether it is session locked. This is useful for viewing a\ndocument without editing or session locking it. The data gets migrated but not saved.\n\nIf the document has never been loaded, the promise will return `nil`.\n\n[DataStoreGetOptions.UseCache](https://create.roblox.com/docs/reference/engine/classes/DataStoreGetOptions#UseCache) is disabled.",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T?>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 184,
                "path": "src/Collection.luau"
            }
        },
        {
            "name": "remove",
            "desc": "Removes the data of the document with `key`.\n\nIf a document is open while `remove` is called, the open document will fail to save/close and the data will still be removed.",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 216,
                "path": "src/Collection.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Collection",
    "desc": "Collections are analagous to [GlobalDataStore].",
    "source": {
        "line": 17,
        "path": "src/Collection.luau"
    }
}