Class representing a player storage. PlayerMemoryStorage
The namespace of the storage.
"hoshimiplayer" Copy
"hoshimiplayer"
console.log(storage.namespace); // "hoshimiplayer" Copy
console.log(storage.namespace); // "hoshimiplayer"
Get all key-value pairs in the storage.
An object containing all key-value pairs in the storage, excluding internal keys.
const all = await storage.all();console.log(all); // { key1: "value1", key2: "value2" } Copy
const all = await storage.all();console.log(all); // { key1: "value1", key2: "value2" }
Build a key from the given parts.
The parts to build the key from.
The built key.
const key = storage.buildKey("part1", "part2", "part3"); Copy
const key = storage.buildKey("part1", "part2", "part3");
Clear the storage.
Scary, right?
await storage.clear(); Copy
await storage.clear();
Delete the value using the key.
The key to delete the value from.
Returns true if the key was deleted.
const success = await storage.delete("key");console.log(success); // true Copy
const success = await storage.delete("key");console.log(success); // true
Get all entries in the storage.
The entries in the storage.
const entries = await storage.entries();console.log(entries); // [["key1", "value1"], ["key2", "value2"]] Copy
const entries = await storage.entries();console.log(entries); // [["key1", "value1"], ["key2", "value2"]]
Get the value using the key.
The key to get the value from.
The value of the key.
const value = await storage.get("key");console.log(value); // "value" Copy
const value = await storage.get("key");console.log(value); // "value"
Check if the storage has the key.
The key to check.
Return true if the key exists.
const exists = await storage.has("key");console.log(exists); // true Copy
const exists = await storage.has("key");console.log(exists); // true
Get all keys in the storage.
The keys in the storage.
const keys = await storage.keys();console.log(keys); // ["key1", "key2"] Copy
const keys = await storage.keys();console.log(keys); // ["key1", "key2"]
Set the value using the key.
The key to set the value to.
The value to set.
Did you know this can be async?
await storage.set("key", "value"); Copy
await storage.set("key", "value");
Get the size of the storage.
The size of the storage.
const size = await storage.size();console.log(size); // 2 Copy
const size = await storage.size();console.log(size); // 2
Get all values in the storage.
The values in the storage.
const values = await storage.values();console.log(values); // ["value1", "value2"] Copy
const values = await storage.values();console.log(values); // ["value1", "value2"]
Class representing a player storage. PlayerMemoryStorage