CREATE YOUR WORLD
Data Storage

World DataStorage

7min
zepeto's datastorage is a remote database that stores and manages user gameplay data on a per world basis it is suitable for storing user gameplay data that needs to be maintained or updated across multiple play sessions, as it is stored and managed by userid manage your users' play data using the api https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/ available on the zepeto multiplay server you can view and modify user specific play data stored in data storage from the world data management menu in zepeto studio 📘 please refer to the following guide \[ world data management docid 3yvxe1hh9xgsleety amp ] data storage api 📘 please refer to the following api reference zepeto multiplay datastorage api https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage please fill out the server code index ts sandbox on the local server in the unity editor environment, data is not preserved when the server is shut down and run again after world deployment, data is stored in zepeto db and maintained data won't be saved if the rules below aren't satisfied no value is provided a value that cannot be stored is entered data storage constraints key length limit 50 characters only alphabets, numbers, and underscore ( ) are allowed in the key maximum number of keys 1000 per user id maximum value data size 500,000 characters note that value data is serialized along with an internal identifier when stored on the actual server use with a safety margin data storage api call restrictions get (per minute) 200 times set (per minute) 200 times read / write / delete data for a single key you can read, write, and delete data for a single key in the datastorage of the local player using datastorage get https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/#get , datastorage set https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/#set and datastorage remove https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/#remove import { datastorage } from 'zepeto multiplay datastorage'; export default class extends sandbox { // async onjoin(client sandboxplayer) { // load local player's data storage const playerstorage datastorage = client loaddatastorage(); // get the value associated with the key 'level' &#x9; let playerlevel = await playerstorage get("level") as number; if (playerlevel == null) { playerlevel += 1; } // store incremented value await playerstorage set("level", playerlevel); // remove the data await playerstorage remove("level"); } } read / write data for multiple keys you can read, write, and delete data for multiple keys in the local player's data storage using datastorage mget https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/#mget and datastorage mset https //developer zepeto me/docs/multiplay server/interfaces/zepeto multiplay datastorage datastorage/#mset import { datastorage } from 'zepeto multiplay datastorage'; export default class extends sandbox { // async onjoin(client sandboxplayer) { const storage = client loaddatastorage(); // mset (multi key value) store const success = await storage mset\<number>(\[ { key 'key1', value 1 }, { key 'key2', value 2 } ]); // if successful if (success) { // get the values of key1 and key2 at once const keys = \['key1', 'key2']; const keyvaleus = await storage mget(keys); keys foreach(key => { const value = keyvaleus\[key]; console log(value); }); } } } error handling you can implement appropriate handling for exceptions that occur when calling the datastorage api by referring to the error types defined in datastorageerror https //developer zepeto me/docs/multiplay server/enums/zepeto multiplay datastorage datastorageerror import { datastorage } from 'zepeto multiplay datastorage'; export default class extends sandbox { // async onjoin(client sandboxplayer) { // load local player's data storage const playerstorage datastorage = client loaddatastorage(); try { let playerlevel = await playerstorage get("level") as number; } catch (error) { let systemerror = (error as systemerror); if (systemerror code === datastorageerror unknown || systemerror code === datastorageerror networkerror) { // system error or network error console log(systemerror message); } else if (systemerror code === datastorageerror keyconstraintviolated) { // key constraint violated console log(systemerror message); } else if (systemerror code === datastorageerror valueconstraintviolated) { // value constraint violated console log(systemerror message); } } } } access data storage by user id it is also possible to access a specific user's data storage by userid using datastorage loaddatastorage https //developer zepeto me/docs/multiplay server/namespaces/zepeto multiplay datastorage? highlight=loaddatastorage#loaddatastorage , instead of the local player's data storage const userstorage datastorage = await loaddatastorage(userid); 👍 tip if you want to store data between different worlds, implement it using http request from the multiplay server docid\ p8op0qvuyn jquqket5cq