Aggregation
PaperDB supports basic aggregation via the count() function — useful for stats, metrics, and simple dashboards.
🔢 count()
Returns the number of documents in a collection.
const total = await db.users.count();With Filters
You can apply filters to count only documents matching certain criteria:
const admins = await db.users.count({
filter: {
isAdmin: true,
name: "Bertram Gilfoyle",
},
});Use Cases
- Dashboard metrics
- Pagination setup
- Quick summaries
- Lightweight analytics
More aggregation functions (like sum, avg, etc.) will be added in the future.