run · schreiben

DropCollection

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

Entfernt eine Sammlung und alles darin. Es sagt Ihnen, wie viele Dokumente gingen.

document databasefreenot reversible
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

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}
Dokumente sind, wie viele Sie gerade zerstört

Es kommt nach der Tatsache zurück, nicht vor. Lesen Sie die Zählung selbst zuerst, wenn die Zahl hätte Ihre Meinung geändert — dieser Anruf ist kostenlos.

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)

Eine Sammlung, die nicht vorhanden ist, wird abgelehnt

Anstatt auf etwas zu antworten, das nie existierte — was einen Tippfehler in einem Namen verbergen würde, im genauen Moment spielt ein Tippfehler am wichtigsten eine Rolle.

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.

Es funktioniert auch wenn die Lagerung voll ist

Wie Delete , ist das Abwerfen über die Quote hinaus erlaubt: Es ist, wie man Raum macht, also würde es einen Speicher, der nicht geleert werden kann, zurücklassen.

Was ein Agent damit tun kann

Der offenste Modus ist der einzige, der dies durch ungefragte

Im Planungsmodus wird es direkt abgelehnt. Überall sonst wird es gefragt. Wenn ein Agent von Ihnen nie etwas fallen lassen sollte, sagen Sie es in seinen Anweisungen und beantworten Sie die Aufforderung - der Modus allein ist ein stumpfes Instrument.