Model Mixins
Powerful model enhancement system that extends functionality with reusable, composable patterns
Model mixins extend your database models with powerful behaviors and utilities. Built on a functional composition pattern, mixins allow you to easily combine multiple enhancements together to create more specialized models.
Available Mixins
Double Tie Query Builder provides the following built-in mixins:
Mixin | Description |
---|---|
withAssignProperties | Creates model instances with data assignment capabilities |
withCreatedAt | Automatically adds timestamps when records are created |
withUpdatedAt | Automatically updates timestamps when records are modified |
withGlobalId | Adds global ID functionality for GraphQL-friendly identifiers |
withIdGenerator | Generates unique IDs with custom prefixes |
withSlug | Creates and manages URL-friendly slugs |
withCursorable | Adds cursor-based pagination for efficient list traversal |
Composing Mixins
Mixins can be combined using functional composition to create models with multiple enhanced behaviors:
Creating Custom Mixins
You can create your own custom mixins by following the functional enhancement pattern: