run · let

conta

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

Quanti documenti coinciden. La forma barata de fare una domanda di cui la risposta è un numero.

document databasefree30 s ceiling
Using Python?

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

await storage.run({ action: "count", collection: "orders",
  filter: JSON.stringify({ status: "paid" }) });
// { count: 8412 }
import json

storage.run(action="count", collection="orders",
            filter=json.dumps({"status": "paid"}))
# {"count": 8412}

Por quo no trovar e contar il resultat

contaTrovi ane .longueza
Enviato indietroUn numeroCada documente a correspondir
Coste per teNadaNada — ma il tempo e la memoria sono reali
Correctu su limitesino — un limite limita il numero, senza dicir che ha fatto
Contar un resultado di repercusso è errato non appena c'è un limite

La lunghezza che mide è la pagina, non la total. Quel erro non fa fail — restitue un numero plausible menor, che è peggio.

Renunce dopo trenta secondi

A count over a large collection without a usable index can run long; the ceiling makes it fail rather than hang. When you hit it, the answer is an index on the field you filter by — not a retry.

Quando la stima è sufficiente

Per «important quan grande è questo», collezioni dà una cifra da metadati senza lere ningun cosa. Use count quando il numero dà una decisione.