All Plugins/ORM & Data Modeling/v0.1.0

Veap Categorizable

Official

Polymorphic categorization trait for Veap Models with category hierarchies, slug resolution, and multilingual category support.

bun add @veap/categorizable

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/categorizable
2

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 migrate

Keep 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

Veap Core

@veap/core (^0.1.0)

Required Veap Plugins
NPM Packages
  • @faker-js/faker@^9.4.0

Authors & Maintainers

Veap Core Team

Maintainer

Profile →

Specifications

License
MIT
Type
plugin
Status
official
Repository
GitHub →
veap
Preparing0%