The count() method in noonjs retrieves the total number of documents in a collection that match the given filter. This method is useful when you need to determine the size of a dataset without retrieving all documents, making it efficient for analytics, pagination, or conditional operations.
const result = await client.collection("todos").count();
console.log(result)
// result
// { total: 2 }
const todos = await client.collection("todos").count({ q: { done: { $exists: true } } });
// result
// { total: 1 }