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.
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 }
// ]
// }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
| 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. |
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
Os objetos nidificati sono caminhati a due livelli profonda, punted — customer.email — que è esattamente come filtrare su dies. A lo più 150 campos retorn.
await storage.run({ action: "find", collection: "orders",
filter: JSON.stringify({ "customer.email": "a@example.com" }) });import json
storage.run(action="find", collection="orders",
filter=json.dumps({"customer.email": "a@example.com"}))