entity-models

Guides changes to User and Event domain models backed by MySQL persistence.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/werlang/event-hub --skill entity-models-werlang
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: entity-models
Source: https://github.com/werlang/event-hub/tree/main/.agents/skills/entity-models
Command: npx skills add https://github.com/werlang/event-hub --skill entity-models-werlang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing domain models in an Express and MySQL codebase risks breaking API contracts, password security, and serialization logic. This Skill documents the exact structure, defaults, and safe-change rules for the User and Event models so edits stay consistent across the codebase. ## Core Features & Use Cases - Model Reference: Documents User fields (bcrypt password hashing, role normalization, lowercase email) and Event fields (defaults for category, location, and createdAt). - Filtering Semantics: Explains how listEvents applies date ranges, case-insensitive category matching, and multi-field search through the Mysql driver. - Safe Change Guidelines: Provides a checklist for adding fields across constructor, toJSON, serialize, normalize, schema, and route validation. - Use Case: When adding a new field like event capacity, follow the checklist to update the model, serialization, SQL schema, and API validation without breaking existing contracts. ## Quick Start Ask the assistant to add a new field to the Event model and update all affected serialization, schema, and validation surfaces.

Frequently Asked Questions about entity-models

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

FAQPage Schema
How do I add a new field to the Event model in Express?▼

Update the model constructor, toJSON, serialize, and normalize methods, then adjust the SQL schema columns and route validation. The serialize method converts dates to MySQL datetime strings while normalize converts them back to ISO strings.

How does password hashing work in the User model?▼

The User model hashes passwords with bcrypt.hashSync using a cost factor of 12 and validates them with bcrypt.compareSync. The hash is stored in a private #passwordHash field and never exposed through toJSON.

How does event filtering by category and search work?▼

Category filtering uses case-insensitive exact matching after normalization, while search checks the combined title, description, location, and category fields. Date ranges are pushed into the SQL query through the Mysql driver's range helpers.

Can models run raw SQL queries directly?▼

No, raw SQL execution is private to api/helpers/mysql.js and model code must not call a public driver query method. Cross-table data should be loaded through api/model/relation.js and composed in model code instead of direct joins.

What entities are out of scope for this model layer?▼

Timetable entities such as Professor, Class, Classroom, Subject, and Card are not in this repository. Redis-backed or external API-backed models and entity expansion helpers are also out of scope.