macro_rules! define_scopes {
($entity:ty { $($scope_name:ident $(($($arg:ident : $arg_ty:ty),*))? => $filter:expr),* $(,)? }) => { ... };
}Expand description
Macro to define scopes for an entity
§Example
ⓘ
define_scopes!(animals::Entity {
ForShelter(shelter_id: i64) => Column::ShelterId.eq(shelter_id),
Available => Column::Status.eq("available"),
Species(species: String) => Column::Species.eq(species),
});
// Usage:
let dogs = Animal::scoped(AnimalScope::Species("dog".into())).all().await?;