Skip to content

Releases: nodecosmos/charybdis

v0.4.9

22 Mar 13:14
Compare
Choose a tag to compare

What's new

  • Introduce find, find_first & maybe_find_first native functions for local_secondary_indexes, so now we have all of the following:

    use scylla::CachingSession;
    use charybdis::errors::CharybdisError;
    use charybdis::macros::charybdis_model;
    use charybdis::stream::CharybdisModelStream;
    use charybdis::types::{Date, Text, Uuid};
    
    #[charybdis_model(
        table_name = posts,
        partition_keys = [date],
        clustering_keys = [category_id, title],
        local_secondary_indexes = [title]
    )]
    pub struct Post {
        pub date: Date,
        pub category_id: Uuid,
        pub title: Text,
    }
    
    impl Post {
        async fn find_various(db_session: &CachingSession) -> Result<(), CharybdisError> {
           let date = Date::default();
           let category_id = Uuid::new_v4();
           let title = Text::default();
        
           let posts: CharybdisModelStream<Post> = Post::find_by_date(date).execute(db_session).await?;
           let posts: CharybdisModelStream<Post> = Post::find_by_date_and_category_id(date, category_id).execute(db_session).await?;
           let posts: Post = Post::find_by_date_and_category_id_and_title(date, category_id, title.clone()).execute(db_session).await?;
        
           let post: Post = Post::find_first_by_date(date).execute(db_session).await?;
           let post: Post = Post::find_first_by_date_and_category_id(date, category_id).execute(db_session).await?;
        
           let post: Option<Post> = Post::maybe_find_first_by_date(date).execute(db_session).await?;
           let post: Option<Post> = Post::maybe_find_first_by_date_and_category_id(date, category_id).execute(db_session).await?;
           let post: Option<Post> = Post::maybe_find_first_by_date_and_category_id_and_title(date, category_id, title.clone()).execute(db_session).await?;
        
           // find by local secondary index
           let posts: CharybdisModelStream<Post> = Post::find_by_date_and_title(date, title.clone()).execute(db_session).await?;
           let post: Post = Post::find_first_by_date_and_title(date, title.clone()).execute(db_session).await?;
           let post: Option<Post> = Post::maybe_find_first_by_date_and_title(date, title.clone()).execute(db_session).await?;
        
          Ok(())
        }
    }
  • Refactor charybdis-macros to utilize traits

v0.4.7

21 Mar 20:26
Compare
Choose a tag to compare

What's new

  • Introduce find_first & maybe_find_first native functions for up to 3 primary keys #10
#[charybdis_model(
    table_name = posts,
    partition_keys = [date],
    clustering_keys = [categogry_id, title],
    global_secondary_indexes = []
)]
pub struct Post {...}

// Now we have
post.find_first_by_date(date).execute(db_session).await -> Result<Post, CharybdisError>
post.maybe_find_first_by_date(date).execute(db_session).await -> Result<Option<Post>, CharybdisError>

post.find_first_by_date_and_category_id(date, category_id).execute(db_session).await -> Result<Post, CharybdisError>
post.maybe_find_first_by_date_and_category_id(date, category_id).execute(db_session).await -> Result<Option<Post>, CharybdisError>

post.find_first_by_date_and_category_id_and_title(date, category_id, title).execute(db_session) -> Result<Post, CharybdisError>
post.maybe_find_first_by_date_and_category_id_and_title(date, category_id, title).execute(db_session) -> Result<Option<Post>, CharybdisError>
  • Improved Error Handling 5a723a2
    • now error returns query
    • removed 'unknown' for models

v0.4.5

13 Mar 11:57
Compare
Choose a tag to compare

What's new

  • Introduce maybe_find methods & functions for optional single model queries (ac1e013)
    • maybe_find_by_primary_key
    • maybe_find_by_primary_key_value
    • maybe_find_first
let user = User::new();
user.maybe_find_by_primary_key().execute(db_session).await -> Result<Option<Model>, CharybdisError>

v0.4.4

07 Mar 14:59
Compare
Choose a tag to compare

v0.4.3

29 Feb 14:35
Compare
Choose a tag to compare

What's new

  • local_secondary_indexes are now defined as list of fields. Partition key is derived from partition_keys part of macro declaration and each element in array will result with new local index so now we just do:
    #[charybdis_model(
        table_name = menus,
        partition_keys = [location],
        clustering_keys = [name, price, dish_type],
        global_secondary_indexes = [],
        local_secondary_indexes = [dish_type]
    )]

v0.4.1

21 Feb 13:49
Compare
Choose a tag to compare

What's new

  • updated docs
  • fix: ignore non .rs files in charybdis-migrate

v0.4.0

19 Feb 18:33
e6adf6e
Compare
Choose a tag to compare

Features

  • Add configurable queries with method chaining by in #7
  • Make batch configurable with method chaining in #7
  • Add increment/decrement counter methods in #7

What's new (Breaking changes)

  1. All Operations: find, insert, update, delete now return CharybdisQuery that can be configured before execution.

    let user = user.find_by_primary_key().consistency(Consistency::One).execute(session);
  2. Macro generated operations also return CharybdisQuery so instead of:

    User::find_by_id(session, id).await?;

    we have configurable:

    User::find_by_id(id).consistency(Consistency::All).execute(db_sesison).await?;
  3. Callbacks: We now have only single Callbacks trait that is used for all operation that can accept extension.
    In case extension is not needed, we can use blank ().

  4. Batch Operations: Batch is now coupled with Model and it's created by calling Model::batch() method. It
    can also be configured before execution.

    let batch = User::batch().consistency(Consistency::One).chunked_insert(&session, users, 100).await?;
  5. Counter: Now we have macro-generated increment_<field_name> and decrement_<field_name> model methods to update counter fields.

v0.3.1

13 Feb 19:25
Compare
Choose a tag to compare

What's Changed

  • fix(docs): file path by in #4
  • fix: versioning difference between repository and cargo 7487db6
  • fix(migration): UDT naming issue: 012c0fd
  • feat: enable usage of ignored fields into partial models 5f79634

New Contributors

v0.3.0

06 Feb 10:27
88d961b
Compare
Choose a tag to compare

What's Changed

  • Migration to new driver's Scylla Rust Driver serialization API
  • Introduced --drop-and-replace flag in migrate so one can drop and replace column on type change