code: func (q Query) CountByField(model interface{}, field string) (int, error) {
  	tmpQuery := Q(q.Connection)
  	q.Clone(tmpQuery) //avoid meddling with original query
  
  	res := &rowCount{}
  
  	err := tmpQuery.Connection.timeFunc("CountByField", func() error {
  		tmpQuery.Paginator = nil
  		tmpQuery.orderClauses = clauses{}
  		tmpQuery.limitResults = 0
  		query, args := tmpQuery.ToSQL(&Model{Value: model})
  		//when query contains custom selected fields / executed using RawQuery,
  		//	sql may already contains limit and offset
  
  		if rLimitOffset.MatchString(query) {
  			foundLimit := rLimitOffset.FindString(query)
  			query = query[0 : len(query)-len(foundLimit)]
  		} else if rLimit.MatchString(query) {
  			foundLimit := rLimit.FindString(query)
  			query = query[0 : len(query)-len(foundLimit)]
  		}
  
  		countQuery := fmt.Sprintf("SELECT COUNT(%s) AS row_count FROM (%s) a", field, query)
  		log(logging.SQL, countQuery, args...)
  		return q.Connection.Store.Get(res, countQuery, args...)
  	})
  	return res.Count, err
  }
docs: // CountByField counts the number of records in the database, for a given field.
  //
  //	q.Where("sex = ?", "f").Count(&User{}, "name")