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/commentable2
Apply trait to your domain Model
models/YourModel.ts
typescript
// models/Post.ts
import { Model } from "@veap/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
Start application
bash
bun devMigrations run automatically on boot via MigrationServiceProvider.
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 Kernel
@veap/kernel (^0.1.0)
NPM Packages
@faker-js/faker@^9.4.0
Authors & Maintainers
Veap Core Team
Maintainer