Purpose & Overview
Enables attaching multiple tags to any model through polymorphic relations, supporting tag cloud generation and quick querying.
Installation & Setup
1
Install the package
bash
bun add @veap/taggable2
Apply trait to your domain Model
models/YourModel.ts
typescript
// models/Product.ts
import { Model } from "@veap/core/database";
import { Taggable } from "@veap/taggable";
export class Product extends Taggable(Model) {
static table = "products";
}
// Attaching tags and querying:
const product = await Product.find("product-uuid");
await product.syncTags(["nextjs", "framework", "typescript"]);
const taggedProducts = await Product.query()
.whereTag("nextjs")
.withTags()
.get();3
Run database migrations
bash
bun run veap migrateKeep in mind
- Polymorphic `morphToMany` relation with the central `taggables` table.
- Provides `syncTags(['react', 'nextjs'])` and `attachTags(['new-tag'])` methods.
- Supports automated querying and filtering via `whereTag('react')`.
Dependencies
Authors & Maintainers
Veap Core Team
Maintainer
Specifications
- License
- MIT
- Type
- plugin
- Status
- official
- Repository
- GitHub →
- Issues
- Report issue →