One of the two actions that work on the database rather than on a collection — so there is no collection to pass. The other is overview.
await storage.run({ action: "collections" });
// [{ name: "users", count: 1204 }, { name: "orders", count: 88311 }]storage.run(action="collections")
# [{"name": "users", "count": 1204}, {"name": "orders", "count": 88311}]The count is an estimate
An exact count on a large collection means reading it. For a figure you will act on, use count with a filter; for « roughly how big is this », the estimate is what you want and it is free.
System collections are left out
Internal collections are filtered, so what comes back is what you put there. A collection you created and cannot see here is a sign you are connected to a different database — see the URI path on connect().
const collections = await storage.run({ action: "collections" });
if (!collections.length) {
// Either it is empty, or the connection landed on the wrong database.
// The database is read from the path of the URI: …/mydb
}collections = storage.run(action="collections")
if not collections:
# Either it is empty, or the connection landed on the wrong database.
# The database is read from the path of the URI: …/mydb
pass