Purpose & Overview
Adds polymorphic morphToMany category relations, query scopes (whereCategory, whereInCategories), and automatic slug lookups to any Model.
Installation & Setup
1
Install the package
bash
bun add @veap/categorizable2
Apply trait to your domain Model
models/YourModel.ts
typescript
// models/Article.ts
import { Model } from "@veap/core/database";
import { Categorizable } from "@veap/categorizable";
export class Article extends Categorizable(Model) {
static table = "articles";
}
// Querying with category scopes:
const articles = await Article.query()
.whereCategory("technology")
.withCategories()
.get();3
Run database migrations
bash
bun run veap migrateKeep in mind
- Uses a polymorphic `morphToMany` relation with the `categorizables` table.
- Provides query scopes: `whereCategory('tech')` and `whereInCategories(['tech', 'design'])`.
- Supports automated category name translations when integrated with @veap/translatable.
Dependencies
Authors & Maintainers
Veap Core Team
Maintainer
Specifications
- License
- MIT
- Type
- plugin
- Status
- official
- Repository
- GitHub →
- Issues
- Report issue →