Skip to content

YaDatastoreAPI

This API is used to get datastore and orderedDatastore objects.

Functions

Datastore YaDatastoreAPI.GetDatastore(string name, [string scope])

SERVER ONLY 
ReturnsA datastore object
Create a datastore instance with the provided name and scope
  • name The name of the datastore instance
  • scope Optional parameter. The scope of the instance
1
2
3
4
5
6
7
8
9
 -- example GetDatastore
 local name = "backpack"
 local scope = "users"

 -- Create a datastore with the name 'backpack' and a global scope
 local datastore = YaDatastoreAPI.GetDatastore(name)

 -- Create a datastore instance with the name 'backpack' and the scope 'users'
 local datastore = YaDatastoreAPI.GetDatastore(name, scope)

Datastore YaDatastoreAPI.GetDatastoreWithOptions(string name, DatastoreOptions datastoreOptions, [string scope])

SERVER ONLY 
ReturnsA datastore instance
Create a datastore instance with provided name, scope and options.
  • name The name of the datastore instance
  • datastoreOptions The options for the datastore instance
  • scope Optional parameter. The scope of the instance
1
2
3
4
5
6
7
8
-- example GetDatastoreWithOptions
local name = "backpack"
local scope = "users"
local opts = DatastoreOptions.New()
opts.ShareId = "shareId"

-- Create a datastore instance with the name 'backpack', with options set to be a shared space using its ID, and with scope set to 'users'
local datastore = YaDatastoreAPI.GetDatastoreWithOptions(name, opts, scope)

OrderedDatastore YaDatastoreAPI.GetOrderedDatastore(string name, [string scope])

SERVER ONLY 
ReturnsAn ordered data store instance
Create an ordered datastore instance with the provided name and scope
  • name The name of orderedDatastore
  • scope Optional parameter. The scope of orderedDatastore
1
2
3
4
5
6
7
8
9
 -- example GetOrderedDatastore
 local name = "leaderboard"
 local scope = "users"

 -- Create an ordered datastore instance with the name 'leaderboard' and the scope automatically set to global
 local datastore = YaDatastoreAPI.GetOrderedDatastore(name)

 -- Create an ordered datastore instance with the name 'leaderboard' and the scope set to 'users'
 local datastore = YaDatastoreAPI.GetOrderedDatastore(name, scope)

OrderedDatastore YaDatastoreAPI.GetOrderedDatastoreWithOptions(string name, DatastoreOptions datastoreOptions, [string scope])

SERVER ONLY 
ReturnsA ordered datastore instance
Create a ordered datastore instance with provided name, scope and options.
  • name The name of the orderedDatastore instance
  • datastoreOptions The options for the datastore
  • scope Optional parameter. The scope of the instance
1
2
3
4
5
6
7
8
-- Example GetOrderedDatastoreWithOptions
local name = "leaderboard"
local scope = "users"
local opts = DatastoreOptions.New()
opts.ShareId = "shareId"

-- Return the ordered data store given the name, otpions, and scope
local datastore = YaDatastoreAPI.GetOrderedDatastoreWithOptions(name, opts, scope)