# collections

Canonical URL: https://developers.iagenify.com/sdk/ref/connected-storage/run/collections/
Language: en

`storage.run({ action: "collections" })`

Every collection in a document database, with how many documents each one holds.

Status: document database · free · no collection needed

One of the two actions that work on the database rather than on a collection — so there is no `collection` to pass. The other is [overview](/sdk/ref/connected-storage/run/overview).

```javascript
await storage.run({ action: "collections" });
// [{ name: "users", count: 1204 }, { name: "orders", count: 88311 }]
```

## The count is an estimate {#counts}

> **Read from metadata, not by walking the documents**
>
> An exact count on a large collection means reading it. For a figure you will act on, use count with a filter; for « roughly how big is this », the estimate is what you want and it is free.

## System collections are left out {#system}

Internal collections are filtered, so what comes back is what you put there. A collection you created and cannot see here is a sign you are connected to a different database — see the URI path on [connect()](/sdk/ref/storage/connect).

```javascript
const collections = await storage.run({ action: "collections" });

if (!collections.length) {
  // Either it is empty, or the connection landed on the wrong database.
  // The database is read from the path of the URI: …/mydb
}
```

- [schema](/sdk/ref/connected-storage/run/schema): Ce qu'il y a dans une collection, champ par champ.
- [run()](/sdk/ref/connected-storage/run): Toutes les actions, les garde-fous et ce que chacune coûte.

```python
storage.run(action="collections")
# [{"name": "users", "count": 1204}, {"name": "orders", "count": 88311}]
```

```python
collections = storage.run(action="collections")

if not collections:
    # Either it is empty, or the connection landed on the wrong database.
    # The database is read from the path of the URI: …/mydb
    pass
```
