All Plugins/ORM & Data Modeling/v0.1.0

Veap Commentable

Official

Polymorphic commenting trait for Veap Models with nested comment threads, status moderation, and author associations.

bun add @veap/commentable

Purpose & Overview

Attaches threaded comments and replies to any database model using Veap's polymorphic morphMany relation, complete with moderation states.

Installation & Setup

1

Install the package

bash
bun add @veap/commentable
2

Apply trait to your domain Model

models/YourModel.ts
typescript
// models/Post.ts
import { Model } from "@veap/core/database";
import { Commentable } from "@veap/commentable";

export class Post extends Commentable(Model) {
  static table = "posts";
}

// Adding and querying comments:
const post = await Post.find("post-uuid");
await post.addComment({
  content: "Excellent article!",
  authorName: "Alice",
  status: "approved"
});
3

Run database migrations

bash
bun run veap migrate

Keep in mind

  • Supports nested multi-level threaded comments via the `parent_id` column in the `comments` table.
  • Includes built-in moderation status flags ('pending', 'approved', 'spam').
  • Provides convenience helper methods: `addComment({ content, authorName })` and `approvedComments()`.

Dependencies

Veap Core

@veap/core (^0.1.0)

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%