Skip to content

API reference ​

count ​

Counts the number of documents in a specified collection.

Parameters ​

PropTypeDescription
pathstringThe name of the collection to count documents in.

Returns ​

  • A promise that resolves to the number of documents in the collection.

Example ​

js
const count = await db.count("users");
console.log(count); 
// Output: 5 (if there are 5 documents in the "users" collection)

Released under the SSPL License.