Database Models
Radish generates Mongoose models for each entity defined in your blueprints.
Overview
Models provide the database layer abstraction, handling:
- Schema definitions
- Indexes
- Timestamps (createdAt, updatedAt)
- Owner scoping
- Versioning hooks (if enabled)
Generated Models
Location: .radish/lib/datalayer/server/models/
// .radish/lib/datalayer/server/models/product.model.ts
export const ProductModel = mongoose.model('Product', productSchema);
Features
Automatic Indexes
Models include automatic indexes on:
- Reference fields (
reffields) - Filter fields
- Compound indexes from blueprints
Timestamps
All models include createdAt and updatedAt timestamps.
Owner Scoping
Models support owner-based access control when configured in blueprints.
Versioning
When versioning is enabled, models include hooks to track changes.
Related Documentation
- Repositories - Data access layer built on models
- Contracts - Type definitions
- Versioning - Version tracking features