Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: a macro for expressions like WRITETIME(field)/TTL(field) #43

Open
kakserpom opened this issue Jun 24, 2024 · 3 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kakserpom
Copy link

Example:

#[charybdis_model(
    table_name = users,
    partition_keys = [id],
    clustering_keys = [],
)]
pub struct User {

    id: Uuid,
    #[charybdis_expr("WRITETIME(id)")]
    id_writetime: Option<Timestamp>,
    tags: Set<Text>,
    post_ids: List<Uuid>,
}

id_writetime will be a read-only field (ignored by insert() and update())

SELECT queries will include WRITETIME(id) and the column will be mapped to id_writetime

What do you think?

@GoranBrkuljan
Copy link
Member

GoranBrkuljan commented Jun 25, 2024

I would recommend the following syntax:

#[charybdis_model(
    table_name = users,
    partition_keys = [id],
    clustering_keys = [],
)]
pub struct User {
    id: Uuid,
    username: Uuid,
    #[charybdis(writetime = "username")]
    username_wt: Option<Timestamp>,
}

Note that we can not use writetime on primary key columns, so we need to panic! if users try to.

@GoranBrkuljan GoranBrkuljan added the enhancement New feature or request label Jun 25, 2024
@kakserpom
Copy link
Author

Looks good. Will you implement this? :-)

@GoranBrkuljan
Copy link
Member

I am quite busy these few weeks. I will probably just do small updates and fixes until mid-July.

@GoranBrkuljan GoranBrkuljan added the help wanted Extra attention is needed label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants