# Storage

With storage class, we can save user's data. to do this we should create a class in the database and after that, we can store our user data. It helps us to manage different data for any purpose.

# Create Class

We can have classes like sets, weapons and etc, we want to store data. For example, here we've created a weaponsUsersHave class to store data of user weapons which that user bought. To create classes we should use DataObject and create new instance of that and then use CreateClass method to send our request.

    DataObject data = new DataObject("weaponsUsersHave");
    data.add("weapon-1", "M16");
    data.add("weapon-2", "M4");

    client.Storage.CreateClass(data, (res) => { Debug.Log(res.Message); });

Supported types

Types
String
int
float
double
byte

to save bytes you should convert bytes to string

    string stringData = Convert.ToBase64String(file.bytes);

# Update Class

If the user creates a class we can update them by their keys. for doing that we can use UpdateClass method.

    DataObject data = new DataObject("weaponsUsersHave");
    data.add("weapon-1", "AK117");
    data.add("weapon-2", "XPR-50");
    data.add("weapon-3", "Type 25");

    client.Storage.UpdateClass(data, (res) => { Debug.Log(res.Message); });

# Fetch Data

After creating the class we can fetch data by using FetchData method

    client.Storage.FetchData("weaponsUsersHave", (res) =>
    {
        Debug.Log(res.Message);
        Debug.Log(res.Data[0]["weapon-1"]);
    });

# Increment Value

If we have numeric values we can increase or decrease them by using IncrementValue method

    DataObject data = new DataObject("info");
    data.increment("xp", 2);
    client.Storage.IncrementValue(data, (res) => {});

Here we add 2 more value to our XP

TIP

For decreasing just put minus

# Delete Object

For deleting the whole class we can use DeleteObject method

    client.Storage.DeleteObject("info", (res) => {});