Module Core.Storage

Модуль для работы с IStorage и IStorageArray.

Storage Array

example
interface MyStorageArray<T = unknown> extends StorageArray<T> {
myProperty: number;
myMethod(): string;
}

class MyStorageArrayInternal extends StorageArrayInternal implements MyStorageArray {
myProperty = 0;
myMethod(): string {
return this.myProperty.toString();
}
}

namespace MyStorageArray {
export function from(
storage: IStorageArray
): MyStorageArray {
return StorageArray.from(
storage,
{
factory: (s, o) => new MyStorageArrayInternal(s, o),
observable: false
}
);
}

export function is(arr: unknown): arr is MyStorageArray {
return StorageArray.is(arr, MyStorageArrayInternal);
}
}

const myArr = MyStorageArray.from([]);
myArr.myMethod(); // "0"
MyStorageArray.is(myArr); // true
Array.isArray(myArr) // true

Storage Map

class MyStorageMap<T = unknown> extends StorageMap<T> {
myProperty = 0;
myMethod(): string {
return this.myProperty.toString();
}
}

Storage Object

example
class MyStorageObject extends StorageObject {
myProperty = 0;
myMethod(): string {
return this.myProperty.toString();
}
}

StorageAccessor

example
const info = request.info; // IStorage
const sa = new StorageAccessor(info);
// get from storage
const txt = sa.tryGetString('SomeTxt');
const users = sa.tryGetGuidArray('Users');

// set to storage
sa
.setGuid('ID', Guid.newGuid())
.setString('Txt', 'new text');

Index

Classes

Interfaces

Type Aliases

Variables

Functions - Type Guards

Generated using TypeDoc