Skip to content

feat: add count_for_filters and count methods via #[es_repo(count)]#118

Open
nicolasburtey wants to merge 1 commit intomainfrom
feat/count-for-filters-v2
Open

feat: add count_for_filters and count methods via #[es_repo(count)]#118
nicolasburtey wants to merge 1 commit intomainfrom
feat/count-for-filters-v2

Conversation

@nicolasburtey
Copy link
Copy Markdown
Member

@nicolasburtey nicolasburtey commented Apr 1, 2026

Summary

Adds opt-in count attribute to the EsRepo derive macro. When #[es_repo(count)] is set, generates:

  • count_for_filters(filters) -> Result<i64> — SELECT COUNT(*) with the same filter columns as list_for_filters
  • count() -> Result<i64> — convenience wrapper calling count_for_filters(Default::default())

Also derives Clone on generated filter structs.

Usage

#[derive(EsRepo)]
#[es_repo(entity = "Customer", count, columns(...))]
pub struct CustomerRepo { pool: PgPool }

Companion PRs

🤖 Generated with Claude Code

Add opt-in `count` attribute to the EsRepo derive macro. When enabled,
generates `count_for_filters()` and `count()` methods that execute
SELECT COUNT(*) queries using the same filter columns as list_for_filters.

Also derives Clone on generated filter structs to support passing
filters to both list and count calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@nicolasburtey nicolasburtey force-pushed the feat/count-for-filters-v2 branch from 240bde9 to 529e72a Compare April 10, 2026 17:07
@nicolasburtey nicolasburtey changed the title chore: add fly to devshell, make crate publish idempotent feat: add count_for_filters and count methods via #[es_repo(count)] Apr 10, 2026
@nicolasburtey nicolasburtey marked this pull request as ready for review April 10, 2026 17:13
@bodymindarts
Copy link
Copy Markdown
Member

Blanket clone won’t work because we can’t garuantee all fields to be clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants