# Schema

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

`storage.run({ action: "schema", collection })`

I campi vissuti in documenti recenti di una collezion, con i loro tipi. Suficiente per scriver una interrogazione senza addichire.

Status: document database · free · sampled, not declared

Una base di documenti non ha schema da lere, quindi questo costruisce uno da guarding: i vinte documenti più recents, ogni campo che porta, e i tipi che vide.

```javascript
await storage.run({ action: "schema", collection: "orders" });

// {
//   sampled: 20,
//   fields: [
//     { field: "_id",            types: ["objectId"], seenIn: 20 },
//     { field: "amount",         types: ["number"],   seenIn: 20 },
//     { field: "customer",       types: ["object"],   seenIn: 20 },
//     { field: "customer.email", types: ["string"],   seenIn: 19 },
//     { field: "refundedAt",     types: ["date", "null"], seenIn: 4 }
//   ]
// }
```

## Lectura proa {#reading}

| Segnal | Significado |
| --- | --- |
| vistoIn iguals amostra | Present on every document sampled. |
| vistoBeno abaixo del campeonato | Opcional, o appena aggiunto. |
| Diversi tipus su un campo | Non è coerente — maneja ambed, o fix i dadi. |
| Un campo non assente complete | Non nei vents recents. Potrebbe ancora existere in anzian. |

> **Venti documenti recenti è un esempio, non un contrat**
>
> Un campo che ha cessat di essere scrit un an fa non va aparecer, e un aggiunto ieri va dominar. Ti dice come interrogare i dati di oggi; non describe tutto in là.

## Nesting e dimensiòn {#nesting}

Os objetos nidificati sono caminhati a due livelli profonda, punted — `customer.email` — que è esattamente come filtrare su dies. A lo più 150 campos retorn.

```javascript
await storage.run({ action: "find", collection: "orders",
  filter: JSON.stringify({ "customer.email": "a@example.com" }) });
```

- [trov](/pt/sdk/ref/connected-storage/run/find): Lire les documents, une fois qu'on sait quoi demander.
- [run()](/pt/sdk/ref/connected-storage/run): Tutes les actions, les garde-fous et ce que chaque coute.

```python
storage.run(action="schema", collection="orders")

# {
#   "sampled": 20,
#   "fields": [
#     {"field": "_id",            "types": ["objectId"], "seenIn": 20},
#     {"field": "amount",         "types": ["number"],   "seenIn": 20},
#     {"field": "customer",       "types": ["object"],   "seenIn": 20},
#     {"field": "customer.email", "types": ["string"],   "seenIn": 19},
#     {"field": "refundedAt",     "types": ["date", "null"], "seenIn": 4}
#   ]
# }
```

```python
import json

storage.run(action="find", collection="orders",
            filter=json.dumps({"customer.email": "a@example.com"}))
```
