adonisjs-models

Standardize AdonisJS Lucid model definitions with decorators, relationships, and hooks.

2|1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-models
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adonisjs-models
Source: https://github.com/omakei/adonisjs-architecture-skill/tree/main/adonisjs/skills/adonisjs-models
Command: npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-models

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Lucid ORM models provide the data layer for AdonisJS applications, but patterns vary and business logic can creep into models. This Skill defines standardized model patterns for columns, relationships, computed properties, hooks, and safe serialisation to improve consistency and maintainability.

Core Features & Use Cases

  • Define columns and their types via decorators to ensure type-safety and serialisation.
  • Define relationships (belongsTo, hasMany, hasOne, manyToMany) to model domain entities and navigable aggregates.
  • Implement computed properties (accessors) for derived state without business logic in models.
  • Use model hooks for lifecycle side effects while keeping core business rules in services/actions.
  • Apply scopes, soft deletes, and mixins/traits to compose reusable behaviour.
  • Organize models with clear structure, naming, and versionable patterns for maintainability across projects.

Quick Start

Scaffold a new AdonisJS Lucid model with columns, relations, hooks, and optional features following the patterns shown.

Frequently Asked Questions about adonisjs-models

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define columns and relationships in AdonisJS Lucid models?

To define Lucid models, use decorator-based columns for type safety and map relationships like belongsTo, hasMany, hasOne, and manyToMany to structure domain entities and navigable aggregates.

What is the best way to keep business logic out of AdonisJS ORM models?

The best way to keep business logic out of ORM models is implementing hooks for lifecycle side effects and accessors for derived state, ensuring core business rules remain in domain services.

Can I use soft deletes and mixins with AdonisJS Lucid?

Yes, you can apply soft deletes, scopes, and mixins to compose reusable behavior in AdonisJS Lucid models, standardizing patterns for maintainability across multiple projects.

How do I serialize AdonisJS models safely without exposing sensitive columns?

Serialize AdonisJS models safely by using decorator-based column definitions and serialization patterns that ensure type safety and clear separation of domain services from data structures.

When should I use custom table and primary keys in Lucid ORM?

Use custom table and primary keys in Lucid ORM when standardizing model definitions for specific database entities, ensuring clear structure, naming, and versionable patterns for maintainability.