#[derive(DeriveEntityModel)]
{
// Attributes available to this derive:
#[sea_orm]
}
Expand description
This derive macro is the ‘almighty’ macro which automatically generates Entity, Column, and PrimaryKey from a given Model.
§Usage
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub title: String,
#[sea_orm(column_type = "Text")]
pub text: String,
}
Entity should always have a primary key. Or, it will result in a compile error. See https://github.com/SeaQL/sea-orm/issues/485 for details.
ⓘ
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "posts")]
pub struct Model {
pub title: String,
#[sea_orm(column_type = "Text")]
pub text: String,
}