await storage.run({ action: "dropCollection", collection: "temp_import" });
// { ok: true, dropped: "temp_import", documents: 48211 }storage.run(action="dropCollection", collection="temp_import")
# {"ok": True, "dropped": "temp_import", "documents": 48211}Vuelve después del hecho, no antes. Lee el conteo primero si el número hubiera cambiado de opinión, esa llamada es gratis.
const { count } = await storage.run({ action: "count", collection });
if (count > 0) throw new Error(`${collection} still holds ${count} documents`);
await storage.run({ action: "dropCollection", collection });count = storage.run(action="count", collection=collection)["count"]
if count > 0:
raise RuntimeError(f"{collection} still holds {count} documents")
storage.run(action="dropCollection", collection=collection)Una colección que no está allí se rechaza
En lugar de responder «hecho» por algo que nunca existió —que ocultaría un error tipográfico en un nombre, en el momento exacto en que más importa un error tipográfico.
const existing = await storage.run({ action: "collections" });
if (!existing.some((c) => c.name === collection)) {
// Nothing to drop. A misspelling here would otherwise look like success.
}existing = storage.run(action="collections")
if not any(c["name"] == collection for c in existing):
pass # Nothing to drop. A misspelling here would otherwise look like success.Funciona incluso cuando el almacenamiento está lleno
Como borrar, se permite bajar más allá de la cuota: es la forma de hacer espacio, por lo que rechazarlo dejaría un almacenamiento que no se puede vaciar.
Lo que un agente puede hacer con él
En el modo de planificación se rechaza de plano. En todas partes se pide. Si un agente suyo nunca debe dejar caer nada, dígalo en sus instrucciones y responda al aviso — el modo por sí solo es un instrumento contundente.