modkit-db-macros
Procedural macros for the modkit-db secure ORM layer.
#[derive(Scopable)]
Automatically implements ScopableEntity for a SeaORM entity based on attributes.
IMPORTANT: All four scope dimensions must be explicitly specified. No implicit defaults.
Example
use sea_orm::entity::prelude::*;
use modkit_db::secure::Scopable;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Scopable)]
#[sea_orm(table_name = "users")]
#[secure(
tenant_col = "tenant_id",
resource_col = "id",
no_owner,
no_type
)]
pub struct Model {
#[sea_orm(primary_key)]
pub id: Uuid,
pub tenant_id: Uuid,
pub email: String,
}
Attributes
Each scope dimension requires exactly one declaration:
- Tenant:
tenant_col = "column_name"ORno_tenant - Resource:
resource_col = "column_name"ORno_resource - Owner:
owner_col = "column_name"ORno_owner - Type:
type_col = "column_name"ORno_type - Unrestricted:
unrestricted(forbids all other attributes)
Note on OData Macros
OData-related derives like ODataFilterable have been moved to modkit-odata-macros.
Use that crate for OData protocol macros.