文件数据库没有可阅读的图案,因此,它通过查看来构建一个图案:20个最新文件、每个文件的每个字段和所看到的类型。
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}
# ]
# }读得当
| 信号信号 | 含义 |
|---|---|
| 以 相等的样本方式 | 在每个文件样本中都提供。 |
| 抽样调查在下层 | 或新增加的可选。 |
| 在一个字段上的若干类型 | 它不一致——处理或确定数据。 |
| 完全没有字段 | 在最近二十年,它可能仍然存在于老的身上。 |
20份最近的文件是抽样文件,不是合同
一年前停止写入的字段将不会出现, 昨天添加的字段将占主导地位。 它告诉你如何查询今天的数据; 它并不描述里面的一切。
括号与大小
嵌套对象在深层两层,点形—— customer.email 最多150个田地会回来
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"}))