stacks-models

Define and manage Stacks data models with schemas, validations, and relationships.

622|17|Updated Apr 26, 2022
One-click install
npx skills add https://github.com/stacksjs/stacks --skill stacks-models
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stacks-models
Source: https://github.com/stacksjs/stacks/tree/main/.claude/skills/stacks-models
Command: npx skills add https://github.com/stacksjs/stacks --skill stacks-models

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Skill helps developers define, validate, and generate data models in Stacks, covering defineModel() usage, attribute validation, factories, relationships, and common traits to accelerate backend development.

Core Features & Use Cases

  • DefineModel API for declarative model schemas and storage mappings
  • Relationships: hasOne, hasMany, belongsTo, belongsToMany
  • Traits: useAuth, useUuid, useTimestamps, useSearch, useApi, billable, taggable, categorizable, commentable, likeable, observe
  • Computed properties (get/set) and model generation templates
  • Use cases: scaffold framework models, implement application models, seed data and validation rules

Quick Start

Create a new model with the generator and begin wiring attributes, relations, and traits in your app.

Frequently Asked Questions about stacks-models

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

FAQPage Schema
How do I define data models and set up attribute validation in a Stacks backend?

Define data models in a Stacks backend using the declarative defineModel API to establish schemas, map storage, and apply attribute validation rules for backend services. This accelerates development by generating framework and application models automatically.

Can I manage complex ORM relationships like belongsToMany with Stacks models?

Yes, Stacks models support complex ORM relationships including hasOne, hasMany, belongsTo, and belongsToMany. You can declaratively configure these associations within your defineModel schema to manage relational data structures.

What traits are available for Stacks data models?

Stacks data models provide traits like useAuth, useUuid, useTimestamps, useSearch, useApi, taggable, categorizable, commentable, likeable, and observe. These traits allow you to rapidly add common functional behaviors to your application models.

Does Stacks support computed properties for data model schemas?

Yes, Stacks supports computed properties for data model schemas through get and set methods. This allows you to dynamically calculate and manipulate attribute values directly within your defined models.

What is the best way to scaffold framework models and seed validation rules?

The best way to scaffold framework models and seed validation rules is using the Stacks model generation templates. This approach automatically generates framework and application models while wiring attributes, relations, and traits seamlessly.

Do I need a separate library to add search and API capabilities to my ORM models?

No, you do not need a separate library to add search and API capabilities. Stacks models include useSearch and useApi traits, enabling you to integrate these functionalities directly into your model definitions.