# list()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/storage/list/
Language: zh

`api.storage.list() → Promise<ConnectedStorage[]>`

帐户上每个活性储存,最最新的储存,都是最先——每个都准备使用,而不是仅仅描述。

Status: GET /api/storage · free · real objects

与大多数列名不同,这些并非简单记录:每个记录都是 [连接连接的系统](/zh/sdk/ref/connected-storage) 您可以拨打 `run()` 直线前进

```javascript
const all = await api.storage.list();

for (const s of all) {
  console.log(`${s.label} · ${s.type}${s.service ? ` (${s.service})` : ""}${s.isDefault ? " · default" : ""}`);
}

// And use one immediately
const base = all.find((s) => s.service === "nosql");
await base.run({ action: "collections" });
```

## 回到什么 {#shape}

活动存储仅是活动存储, 被删除的存储不在列表中。 最新列表先是, 并且没有限制: 账户有少数这些, 不是数千个 。

## 找到一个你指的 {#finding}

```javascript
const all = await api.storage.list();

const byLabel = all.find((s) => s.label === "Archive");
const computers = all.filter((s) => s.type === "filesystem");
const phones = all.filter((s) => s.type === "phone");
const ours = all.filter((s) => s.provider === "iagenify");
const fallback = all.find((s) => s.isDefault);
```

> **以标签方式决定一次, 然后保留id**
>
> 标签并非独一无二, 账户持有人可以重命名一个。 在每个运行中查找一个以名称命名的存储处, 取决于显示名称 。

## 几个电脑是正常的 {#machines}

每台机器 SDK 运行中运行成为自己的存储器。 每次重新启动登记时,会话缓存会丢失的部署每次都会有新的部署,因此,清单上的一堆接近同义电脑是一个值得读取的信号。

```javascript
const machines = (await api.storage.list()).filter((s) => s.type === "filesystem");

if (machines.length > expected) {
  for (const m of machines) console.log(m.label, m.hostname, m.createdAt);
  // Near-identical entries usually mean the session cache is not persisting.
}
```

## 持有违约者 {#default}

完全一匹 `isDefault`。在删除了持有该存储器的存储器之后,该列表将显示您是如何看待哪个存储器接管了该存储器的。

- [remove()](/zh/sdk/ref/storage/remove): 与一个已断开连接,而继承默认的,
- [连接连接的系统](/zh/sdk/ref/connected-storage): 清单中每个项目能做些什么。

```python
storages = api.storage.list()

for s in storages:
    service = f" ({s.service})" if s.service else ""
    print(f"{s.label} · {s.type}{service}{' · default' if s.is_default else ''}")

# And use one immediately
base = next(s for s in storages if s.service == "nosql")
base.run(action="collections")
```

```python
storages = api.storage.list()

by_label = next((s for s in storages if s.label == "Archive"), None)
computers = [s for s in storages if s.type == "filesystem"]
phones = [s for s in storages if s.type == "phone"]
ours = [s for s in storages if s.provider == "iagenify"]
fallback = next((s for s in storages if s.is_default), None)
```

```python
machines = [s for s in api.storage.list() if s.type == "filesystem"]

if len(machines) > expected:
    for m in machines:
        print(m.label, m.machine_id, m.created_at)
    # Near-identical entries usually mean the session cache is not persisting.
```
