Parâmetros
collectionstringobrigatório*Su una base de dadi documenta.
filterJSON textobrigatório*Quali documenti. Necessita vat all: true.
manybooleanfalse elimina un solo documento. Predefinito: ogni match.
allbooleanObligatoriu di accettare un filtro vuoto.
keystringobrigatório*Sobre l'ogget de stoccatura: qual ogget.
// Documents
await storage.run({ action: "delete", collection: "sessions",
filter: JSON.stringify({ expiresAt: { $lt: new Date().toISOString() } }) });
// { ok: true, deletedCount: 142 }
// An object
await storage.run({ action: "delete", key: "invoices/2026/01/a.pdf" });import json
from datetime import datetime, timezone
# Documents
storage.run(action="delete", collection="sessions",
filter=json.dumps({"expiresAt": {"$lt": datetime.now(timezone.utc).isoformat()}}))
# {"ok": True, "deletedCount": 142}
# An object
storage.run(action="delete", key="invoices/2026/01/a.pdf")Update tocca uno a meno che si dice molti: true; cancella elimina tutti loro a meno che si dice molti: false. I due predefiniti differen, e la differenza non è recuperabile in una direzion.
Un filtro vazio è negat
// Refused: this would empty the collection
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}) });
// Accepted: you said so, explicitly
await storage.run({ action: "delete", collection: "logs",
filter: JSON.stringify({}), all: true });import json
# Refused: this would empty the collection
storage.run(action="delete", collection="logs", filter=json.dumps({}))
# Accepted: you said so, explicitly
storage.run(action="delete", collection="logs", filter=json.dumps({}), all=True)La guardia vara prima che nulla arrivi alla base di dati, e prima che un agente è chiesto permesse — per cui la forma pericolosa è interrotta senza necessitare di giudizio di ningun.
Conta prima di cancellare
Il medesimo filtro, contat prima, ti dice ce che sta per partir. È gratis, ed è la sola vista preliminare che si obtiene.
const { count } = await storage.run({ action: "count", collection, filter });
if (count > 1000) throw new Error(`that filter matches ${count} documents — check it`);
await storage.run({ action: "delete", collection, filter });count = storage.run(action="count", collection=collection, filter=filter)["count"]
if count > 1000:
raise ValueError(f"that filter matches {count} documents — check it")
storage.run(action="delete", collection=collection, filter=filter)La cancellazione funziona anche quando il stoccaggio è pieno
I scrivis sono respintos al dispass la quota; eliminas no lo sono. Issí è como se fa spazio — un storage non si può vaciare perché è pieno sarebbe un cappuccio.