Skip to content

Datastore

Compey edited this page Jan 19, 2023 · 2 revisions
A JavaScript wrapper for the ROBLOX OpenCloud API.


Datastore

GetAsync

GetAsync lets you fetch the value of a particular Key in a datastore.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.GetAsync("DATASTORE_NAME", "KEY_NAME")

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.GetAsync("DATASTORE_NAME", "KEY_NAME")
Returns: Promise<string|number|boolean|undefined>

SetAsync

SetAsync lets you set the value of a particular Key in a datastore.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.SetAsync("DATASTORE_NAME", "KEY_NAME", "VALUE")

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.SetAsync("DATASTORE_NAME", "KEY_NAME", "VALUE")
Optional Arguments: matchVersion: string, exclusiveCreate: Boolean
Returns: Promise<DatastoreSetResponse|undefined>

RemoveAsync

RemoveAsync lets you remove a key from a datastore.

CommonJS

const { Datastore } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.RemoveAsync("DATASTORE_NAME", "KEY_NAME")

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.RemoveAsync("DATASTORE_NAME", "KEY_NAME")
Returns: Promise<undefined>

ListKeysAsync

ListKeysAsync lets you fetch a list of keys in a datastore.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.ListKeysAsync("DATASTORE_NAME")

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.ListKeysAsync("DATASTORE_NAME")
Returns: Promise<DatastoreSetResponse|undefined>

ListDataStoresAsync

ListDataStoresAsync lets you fetch a list of datastores in a universe.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.ListDataStoresAsync()

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.ListDataStoresAsync()
Optional Arguments: prefix: string, limit: string, cursor: string, AllScopes: boolean
Returns: Promise<DatastoreEntries|undefined>

GetVersionAsync

GetVersionAsync lets you fetch a key from its version.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.GetVersionAsync("DATASTORE_NAME", "KEY_NAME", "08DA9790C75527F0.0000000011.08DA9798C9BEB578.01")

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.GetVersionAsync("DATASTORE_NAME", "KEY_NAME", "08DA9790C75527F0.0000000011.08DA9798C9BEB578.01")
Optional Arguments: scope: string
Returns: Promise<string|number|boolean|undefined>

IncrementAsync

IncrementAsync increments a key with an integer value by the given value.

CommonJS

const { Datastore, ClientIntents } = require('rblx.js')

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: [ "datastore" ]
})

await datastore.IncrementAsync("DATASTORE_NAME", "KEY_NAME", 3)

ES6

import { Datastore, ClientIntents } from 'rblx.js'

const datastore = new Datastore({
    apiKey: "API_KEY",
    universeId: "UNIVERSE_ID",
    intents: ClientIntents.Datastore
})

await datastore.IncrementAsync("DATASTORE_NAME", "KEY_NAME", 3)
Returns: Promise<DatastoreSetResponse>