Mixin Scenarios
Use this page when you want to apply mixin-backed runtime behavior in real services and controllers.SoftDeletes
Use this when deletes should be reversible. Use one schema declaration:EagerLoading
Use this when one service call should return a model plus its relations. Important runtime rule:- eager loading requires explicit relation methods on the model instance
- schema relation metadata alone does not make
load()orwith()available
Serialize
Use this when API responses should hide internal fields or append computed fields.toObject() in services and controllers. toJSON() returns a string.
Casts
Use this when booleans, dates, and JSON should be normalized automatically after reads.Scope
Use this when some records should be filtered globally fromall() and find().
- scope behavior is in-memory post-fetch filtering
- do not treat it as SQL query optimization
Hooks
Use this when audit logic, side effects, or invalidation should run around writes. Preferred model declaration:- register models with
registerModels([...])before relying on hook flows
PivotHelper
Use this when many-to-many behavior belongs in the service layer.Cache
UseCacheManager and setupCache() at the service boundary for consumer-facing reads.
Recommended consumer rule
- define schema and relations in models
- use mixin-backed behavior in services
- keep controllers thin
- keep cache logic out of controllers