# Class: StoredClassModel (/pixi-vn/index/classes/StoredClassModel)



Defined in: [src/storage/classes/StoredClassModel.ts:33](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L33)

StoredClassModel is a abstract class that contains the methods to store a class in the game.
I suggest you extend this class to create your own stored class.

## Example [#example]

```ts
export class CharacterBaseModel extends StoredClassModel implements CharacterBaseModelProps {
    constructor(id: string, props: CharacterBaseModelProps) {
        super("___character___", id)
        this.defaultName = props.name
        this.defaultSurname = props.surname
    }
    readonly defaultName: string = ""
    get name(): string {
        return this.getStorageProperty<string>("name") || this.defaultName
    }
    set name(value: string) {
        this.setStorageProperty("name", value)
    }
    readonly defaultSurname?: string
    get surname(): string | undefined {
        return this.getStorageProperty<string>("surname") || this.defaultSurname
    }
    set surname(value: string | undefined) {
        this.setStorageProperty("surname", value)
    }
}
```

## Extended by [#extended-by]

* [`CharacterStoredClass`](/pixi-vn/index/classes/CharacterStoredClass)

## Constructors [#constructors]

### Constructor [#constructor]

\> **new StoredClassModel**(`categoryId`, `id`): `StoredClassModel`

Defined in: [src/storage/classes/StoredClassModel.ts:38](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L38)

#### Parameters [#parameters]

##### categoryId [#categoryid]

`string`

The id of the category. For example if you are storing a character class, you can use "characters" as categoryId. so all instances of the character class will be stored in the "characters" category.

##### id [#id]

`string`

The id of instance of the class. This id must be unique for the category.

#### Returns [#returns]

`StoredClassModel`

## Properties [#properties]

### id [#id-1]

\> `readonly` **id**: `string`

Defined in: [src/storage/classes/StoredClassModel.ts:63](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L63)

Is id of the stored class. is unique for this class.

## Methods [#methods]

### getStorageProperty() [#getstorageproperty]

\> `protected` **getStorageProperty**\<`T`>(`propertyName`, `idToUse?`): `T` | `undefined`

Defined in: [src/storage/classes/StoredClassModel.ts:80](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L80)

Get a property from the storage.

#### Type Parameters [#type-parameters]

##### T [#t]

`T` = [`StorageElementType`](/pixi-vn/index/type-aliases/StorageElementType)

#### Parameters [#parameters-1]

##### propertyName [#propertyname]

`string`

The name of the property to get.

##### idToUse? [#idtouse]

`string` = `...`

The id of the instance to get the property.

#### Returns [#returns-1]

`T` | `undefined`

The value of the property. If the property is not found, returns undefined.

#### Default [#default]

```ts
this.id
```

***

### migrateOldStorage() [#migrateoldstorage]

\> `protected` **migrateOldStorage**(`oldCategoryId?`): `void`

Defined in: [src/storage/classes/StoredClassModel.ts:43](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L43)

#### Parameters [#parameters-2]

##### oldCategoryId? [#oldcategoryid]

`string` = `...`

#### Returns [#returns-2]

`void`

***

### setStorageProperty() [#setstorageproperty]

\> `protected` **setStorageProperty**\<`T`>(`propertyName`, `value`): `void`

Defined in: [src/storage/classes/StoredClassModel.ts:71](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/storage/classes/StoredClassModel.ts#L71)

Update a property in the storage.

#### Type Parameters [#type-parameters-1]

##### T [#t-1]

`T`

The type of the value to set. (Deprecated, it is not necessary to specify the type of the value, it will be inferred from the value)

#### Parameters [#parameters-3]

##### propertyName [#propertyname-1]

`string`

The name of the property to set.

##### value [#value]

[`StorageElementType`](/pixi-vn/index/type-aliases/StorageElementType)

The value to set. If is undefined, the property will be removed from the storage.

#### Returns [#returns-3]

`void`
