Releases: nodecosmos/charybdis
v0.4.9
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
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
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
What's new
v0.4.3
What's new
local_secondary_indexes
are now defined as list of fields. Partition key is derived frompartition_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
What's new
- updated docs
- fix: ignore non
.rs
files incharybdis-migrate
v0.4.0
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)
-
All Operations:
find
,insert
,update
,delete
now returnCharybdisQuery
that can be configured before execution.let user = user.find_by_primary_key().consistency(Consistency::One).execute(session);
-
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?;
-
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()
. -
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?;
-
Counter: Now we have macro-generated
increment_<field_name>
anddecrement_<field_name>
model methods to update counter fields.
v0.3.1
v0.3.0
What's Changed
- Migration to new driver's Scylla Rust Driver serialization API
- Introduced
--drop-and-replace
flag inmigrate
so one can drop and replace column on type change