JCC Eloquent ORM
Retrieving Models
Introduction
JCC-Eloquent models expose static retrieval methods through Model + QueryBuilder.
Use these for common fetch patterns before dropping to raw SQL.
Basic retrieval
TypeScript
Query constraints
TypeScript
Existence and value helpers
TypeScript
Select and raw
TypeScript
Aggregates
TypeScript
Advanced where variants
Available static methods include:
whereNot,orWhereNotwhereNotNull,whereNullwhereIn,whereBetween,whereNotBetween,orWhereBetweenwhereExists,orWhereExistswhereDate,whereMonth,whereDay,whereYear,whereTimewhereRaw,orWhereRawwhereLike,orWhereLike
Hydrating raw data
Model.hydrate() converts plain objects (e.g. from a raw query) into model instances:
TypeScript
Also works with eager loading:
TypeScript
Executing without events
Run a block of writes without firing model events (creating, updating, etc.):
TypeScript
Useful in seeders and migrations where lifecycle hooks are unwanted.
Loading relations on existing instances
Use load() to fetch relations after a model is already retrieved:
TypeScript
Saving without events
saveQuietly() persists changes without triggering any model events:
TypeScript
Similarly: updateQuietly(attrs), deleteQuietly().
Summary
- Start with
all,find,where(...).get(), andfirst(). - Use existence/value/aggregate helpers for efficient reads.
- Use
hydrate()to wrap raw query results in model instances. - Use
executeWithoutEvents()in seeders and batch operations. - Use
saveQuietly()/updateQuietly()/deleteQuietly()to skip event hooks. - Use
runQueryand raw clauses only when builder expressions are not enough.