Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix naming
  • Loading branch information
Phillip Leonardo committed Dec 13, 2025
commit e6c8a040e6459f0a46ce5e34a210f7fba562f3b0
6 changes: 3 additions & 3 deletions dsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,18 @@ func (qb *QueryBuilder[T]) KeysOnly() *QueryBuilder[T] {
return qb
}

// Total returns the count of entities matching the current query filters.
// Count returns the count of entities matching the current query filters.
// It uses Datastore's aggregation query to efficiently count without loading entities into memory.
//
// Example:
//
// count, err := dsx.From[User](ctx, db).
// Where("Status", "=", "active").
// Total()
// Count()
//
// Returns 0 and an error if the aggregation query fails or the count result is missing.
// Note: Datastore count aggregations have a default limit of approximately 1 million entities.
func (qb *QueryBuilder[T]) Total() (int64, error) {
func (qb *QueryBuilder[T]) Count() (int64, error) {
aggQuery := qb.query.NewAggregationQuery().WithCount("total")
results, err := qb.db.client.RunAggregationQuery(qb.context, aggQuery)
if err != nil {
Expand Down