Skip to content

v1.1.0

Latest

Choose a tag to compare

@GoranBrkuljan GoranBrkuljan released this 19 Nov 21:38
· 1 commit to main since this release

What's Changed

  • feature: implement find_by_fields_paged in #86
  • update: remove limits for maximum for generated find_by_fields functions by @GoranBrkuljan in #86

Now we have generated find_by_fields functions for all primary key fields, and we have find_by_fields_paged variant that we can use like this:

  #[charybdis_model(
      table_name = posts,
      partition_keys = [date],
      clustering_keys = [category_id, title],
      global_secondary_indexes = [category_id],
      local_secondary_indexes = [title]
  )]
  pub struct Post {
      pub date: Date,
      pub category_id: Uuid,
      pub title: Text,
  }

// paged finders over partition key + clustering keys
 let (paged_posts_iter, paging_state) = Post::find_by_date_and_category_id_paged(date, category_id)
     .page_size(10)
     .execute(db_session)
     .await?;
 let paged_posts = paged_posts_iter.collect::<Result<Vec<Post>, CharybdisError>>()?;

 if let PagingStateResponse::HasMorePages { state } = paging_state {
     let (next_page_iter, next_state) = Post::find_by_date_and_category_id_paged(date, category_id)
         .paging_state(state)
         .page_size(10)
         .execute(db_session)
         .await?;
     let _next_posts = next_page_iter.collect::<Result<Vec<Post>, CharybdisError>>()?;
     assert!(matches!(next_state, PagingStateResponse::NoMorePages));
 }

Full Changelog: v1.0.4...v1.1.0