#[derive(SqlHelper)]
{
// Attributes available to this derive:
#[id]
#[field_name]
#[create_time]
#[update_time]
}
Expand description
自动生成mysql数据库增删改查方法
基于sqlx生成find
、list
、delete
、add
、update
、save_or_update
、new
、new_common
、base_page
、base_count
等方法。
需要在struct上下文中引入sqlx的db对象。
use super::db;
§Examples
#[derive(SqlHelper)]
pub struct Person {
#[id]
pub id: i32,
pub name: String,
pub age: i32,
pub weight: Option<i32>,
#[create_time]
pub create_time: NaiveDateTime,
#[update_time]
pub update_time: NaiveDateTime,
}