Derive macro for sqlx to implement Create, Read, Update, and Delete (CRUD) methods.

Use

adding the following to your project's Cargo.toml: toml [dependencies] co-orm = { virsion = "0.2", features = ["mysql"] } sqlx = { version = "0.6", features = ["mysql","runtime-tokio-native-tls"] } tokio = { version = "1", features = ["full"] } * features: mysql, postgres, sqlite, mssql

Examples

```rust use co_orm::{Crud, FromRow};

[derive(Debug, Crud, FromRow)]

[orm_rename = "users"]

pub struct User { #[orm_pk] pub id: i64,

#[orm_by]
#[orm_update]
#[orm_rename = "name"]
pub name: Option<String>,

#[orm_ignore]
pub add: String,

}

pub async fn getpool() -> Result { MySqlPoolOptions::new() .maxconnections(1) .connect("mysql://root:newpassword@192.168.1.199:3306/hello").await }

[tokio::test]

async fn testquery() { let pool=getpool().await.unwrap(); let u = User::get(&pool, 1).await.unwrap(); println!("get {:?}", u);

}

```

``rust /// #[derive(Crud)] /// generate get, get_by, query_by, update, delete, insert. /// /// attributes: /// /// #[orm_pk] /// default first field is primary key or set. /// /// #[orm_rename= "name"] /// rename table name or field name. /// default table name by struct name to_table_case: UserDetail => user_details. /// default field name by field name to_snake_case: UserDetail => user_detail. /// /// #[orm_ignore] /// ignore field. /// /// #[orm_update] /// only update one field update_field. /// /// #[orm_by] /// generate query_by_field,update_by_field,delete_by_field. /// /// #[derive(FromRow)] /// impl sqlx::FromRow trait. /// /// if use#[derive(FromRow)]macro, must use#[derive(Crud)]macro. /// /// if you don't want to use#[derive(coorm::FromRow)]macro, /// you can use#[derive(sqlx::FromRow)]macro or implsqlx::FromRowtrait. /// /// if using sqlx::FromRow,#[ormignore]add#[sql::defult]` .

```