다음을 통해 공유


Storage interface

일반 이전 JSON 개체를 저장하고 검색하는 스토리지 공급자의 인터페이스입니다.

메서드

delete(string[])

스토리지에서 저장소 항목을 제거합니다.

read(string[])

스토리지에서 저장소 항목 로드

write(StoreItems)

저장소 항목을 스토리지에 저장합니다.

메서드 세부 정보

delete(string[])

스토리지에서 저장소 항목을 제거합니다.

function delete(keys: string[]): Promise<void>

매개 변수

keys

string[]

저장소에서 제거할 항목 키의 배열입니다.

반환

Promise<void>

설명

다음은 스토리지에서 개체를 삭제하는 예제입니다.

await storage.delete(['botState']);

read(string[])

스토리지에서 저장소 항목 로드

function read(keys: string[]): Promise<StoreItems>

매개 변수

keys

string[]

저장소에서 읽을 항목 키의 배열입니다.

반환

Promise<StoreItems>

설명

이 예제에서는 스토리지에서 단일 개체를 읽습니다.

const items = await storage.read(['botState']);
const state = items['botState'] || {};

write(StoreItems)

저장소 항목을 스토리지에 저장합니다.

function write(changes: StoreItems): Promise<void>

매개 변수

changes
StoreItems

스토리지에 쓸 항목의 맵입니다.

반환

Promise<void>

설명

이 예제에서는 수정된 후 스토리지에 개체를 씁니다.

state.topic = 'someTopic';
await storage.write({ 'botState': state });