Class: DocumentStore
Document store provides a document-like access to the database. You can use it to acess any persistent data within the game.
Methods
Name | Description |
---|---|
:get(doc,key) | Returns a document specified by a primary key, or nil if not found. |
:insert(doc,value) | |
:update(doc,key,value_or_func) | |
:upsert(doc,value) |
Method declarations
Method: get
Returns a document specified by a primary key, or nil if not found.
lua
function DocumentStore:get(
doc,
key
) end
Parameters:
- doc (
string
) - The document name - key (
integer
) - The document ID to get
Returns:
boolean|string|number|table|nil
- The value of the document or nil if not found
Method: insert
lua
function DocumentStore:insert(
doc,
value
) end
Parameters:
- doc (
string
) - The document name - value (
boolean|string|number|table
) - The value to insert
Returns:
integer
- The new document ID that was inserted
Method: update
lua
function DocumentStore:update(
doc,
key,
value_or_func
) end
Parameters:
- doc (
string
) - The document name - key (
integer
) - The document ID to update - value_or_func (
boolean|string|number|function|table
) - The value to update, or a callback function
Method: upsert
lua
function DocumentStore:upsert(
doc,
value
) end
Parameters:
- doc (
string
) - The document name - value (
boolean|string|number|table
) - The value to insert or update
Returns:
integer
- The new document ID that was inserted or an existing ID of document that was updated