Wheels Model Generator

Generate CFWheels ORM models with validations, associations, and lifecycle callbacks.

203|108|Updated Jan 13, 2011
One-click install
npx skills add https://github.com/wheels-dev/wheels --skill wheels-model-generator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Wheels Model Generator
Source: https://github.com/wheels-dev/wheels/tree/main/.claude/skills/wheels-model-generator
Command: npx skills add https://github.com/wheels-dev/wheels --skill wheels-model-generator

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill simplifies the creation of CFWheels ORM models, ensuring proper validations, associations, and methods while preventing common Wheels-specific errors like mixed argument styles and missing primary key declarations. It provides a production-ready template to build reliable data layers.

Core Features & Use Cases

  • ORM Model Generation: Creates models with hasMany, belongsTo, hasManyThrough associations.
  • Comprehensive Validations: Supports presence, uniqueness, format, length, numericality, confirmation, inclusion/exclusion, and custom validations.
  • Lifecycle Callbacks: Implements before/after callbacks for validation, save, create, update, and delete events.
  • Critical Fixes: Includes mandatory fixes for setPrimaryKey() and structKeyExists() checks in callbacks, preventing common runtime errors.
  • Use Case: Create a User model that hasMany Tweets and Likes, validates email format and password length, and hashes passwords before saving. This skill ensures all these features are implemented correctly and securely, saving you from common pitfalls.

Quick Start

Example Model:

component extends="Model" { function config() { setPrimaryKey("id"); # CRITICAL! hasMany(name="comments", dependent="delete"); validatesPresenceOf(properties="title"); beforeCreate("setDefaults"); } private function setDefaults() { if (!structKeyExists(this, "count")) { this.count = 0; } } }

Frequently Asked Questions about Wheels Model Generator

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

FAQPage Schema
How do I generate a CFWheels ORM model with validations and associations?

CFWheels model generation creates components with built-in validations (presence, uniqueness, format, length), associations (hasMany, belongsTo, hasManyThrough), and lifecycle callbacks. The Skill produces production-ready templates that enforce setPrimaryKey declarations and structKeyExists checks to prevent common Wheels errors.

What validations can I add to a Wheels model?

Wheels models support presence, uniqueness, format, length, numericality, confirmation, inclusion/exclusion, and custom validations through validatesPresenceOf, validatesUniquenessOf, validatesFormatOf, and similar methods. The Skill structures these properly within the config function.

Can I use beforeCreate and afterCreate callbacks in CFWheels models?

Yes, Wheels models support lifecycle callbacks including beforeCreate, afterCreate, beforeSave, afterSave, beforeUpdate, afterUpdate, beforeDelete, and afterDelete. The Skill ensures these callbacks safely access object properties using structKeyExists to avoid runtime errors.

Why do Wheels models require setPrimaryKey declarations?

setPrimaryKey is mandatory in Wheels model config functions to explicitly declare the primary key column. Without it, the ORM cannot correctly identify record identity, leading to association and query failures. The Skill enforces this critical requirement in all generated models.

What's the best way to structure model associations in CFWheels?

CFWheels model associations use hasMany, belongsTo, and hasManyThrough methods declared in the config function. The Skill generates properly structured associations with correct dependent options (delete, deleteAll) and relationship naming conventions to maintain referential integrity.

How do I prevent common Wheels ORM errors when building models?

Common Wheels errors stem from mixed argument styles, missing setPrimaryKey, and unsafe property access in callbacks. The Skill enforces strict parameter usage, mandates setPrimaryKey declarations, and includes structKeyExists checks in lifecycle callbacks to produce error-free templates.