Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

应该提供只更新某些字段的方法 #263

auuo started this conversation in General
Discussion options

当表中有多个字段,但只需要更新其中部分字段时不方便。如果使用 skips 则需要列出其他所有字段,并且如果表新增了字段这里必须同步进行修改。

我现在只能建一个新的 model 用于更新,比如原表 model:

#[derive(Default)]
#[crud_table(table_name: item)]
pub struct Item {
    pub id: i64,
    pub parent_id: i64,
    pub name: String,
    pub item_type: i8,
    pub size: i64,
    // .... 
    pub create_user_id: i64,
    pub create_time: Option<NaiveDateTime>,
    pub update_time: Option<NaiveDateTime>,
}

当只需要更新 name 时我需要提供一个 model:

#[crud_table(table_name: item)]
pub struct ItemRenameModel {
    pub id: i64,
    pub name: String,
}

如果有其他更新需求,还需要创建更多的 struct

You must be logged in to vote

Replies: 2 comments

Comment options

现在支持了吗

You must be logged in to vote
0 replies
Comment options

非常赞同

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
3 participants
Converted from issue

This discussion was converted from issue #211 on September 29, 2022 08:44.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.