store.list()
按前缀分页列举键和版本元数据,不默认返回值内容。
Syntax
const page = await host.store.list(prefix?, cursor?);
Return value
{ items: Array<{ key: string, version: u64, size: u64 }>, cursor?: StoreCursor }
第一页建立键与元数据快照,并按 NFC 键的 UTF-8 字节无符号字典序递增返回;后续 cursor 只能继续同一快照。StoreCursor 是 1–256 字节的 ASCII base64url 字符串,只能由宿主产生,绑定 appId、prefix 与快照并通过完整性校验。后续调用必须传与第一页逐标量相同的 prefix;不匹配以 invalid-cursor 失败。
每个应用最多同时持有 store.maxListSnapshots 个快照;超出时新第一页以 limit-exceeded 失败,不能逐出仍有效的旧快照。每次成功返回非末页都把该快照的空闲有效期重置为不少于 store.listSnapshotIdleMs;末页、空闲到期或 runtime 结束时释放。过期调用以 cursor-expired 整体失败,不能悄悄切换到新快照。
Parameters
| 参数 | 类型 | 说明 |
|---|---|---|
prefix |
string |
可选的规范化键前缀,默认空字符串 |
cursor |
StoreCursor |
可选;前一页返回的不透明 cursor |
Examples
let cursor;
do {
const page = await host.store.list('documents/', cursor);
for (const item of page.items) show(item.key);
cursor = page.cursor;
} while (cursor);
Errors
特有错误:denied、invalid-key、invalid-cursor、cursor-expired、limit-exceeded。
Requirements
- 能力:
host:store.list - 用户激活:不需要
- 信任档位:green