Explore Models
One of the best ways to understand TeaQL is to start from an existing model instead of starting from a blank file.
TeaQL is model-centric. The generated API quality depends heavily on the quality of the domain model. Exploring existing models helps you learn both:
- how TeaQL expects a domain to be described,
- and what kind of API shape a good model produces.
Why start from an existing model
A good reference model gives you immediate examples of:
- entity naming,
- relationship structure,
- constants and enumerations,
- request patterns,
- aggregate boundaries,
- server-driven view objects,
- query and statistics design.
It also helps your team avoid a common mistake: designing a model that mirrors tables rather than business concepts.
What to inspect first
When reading an existing model, inspect these areas in order:
- Core entities
- What are the main business objects?
- Are they named in business language?
- Relationships
- Which entities are parent-child?
- Which ones are references?
- Which relations are likely aggregate boundaries?
- Constants and states
- Are statuses and scenario types modeled explicitly?
- Generated requests
- Do the generated request methods read clearly?
- Can common business filters be expressed naturally?
- Write scenarios
- Can common save/update flows be represented without large mapping layers?
- Workflow objects
- Are there view objects or service-request forms for workflow-heavy use cases?
What a strong reference model looks like
A strong TeaQL model usually has these qualities:
- stable business terms,
- explicit entity relationships,
- meaningful types and state values,
- reasonable aggregate size,
- clear distinctions between master data, transactional data, and workflow data,
- enough metadata to support readable generated APIs.
If the model is strong, the generated code often reads almost like business pseudocode.
Questions to ask while exploring
Use this checklist when reviewing a model:
- Can developers guess the purpose of an entity from its name alone?
- Do request methods already match the most common query scenarios?
- Can complex graph loading stay readable?
- Are business states modeled as constants instead of string literals spread across code?
- Are workflow entry points modeled clearly?
- Does the model support future customization through
UserContext?
A practical evaluation loop
For each candidate model, try a small set of representative cases:
Q.orders().top(20).comment("Query orders").purpose("Load data").executeForList(ctx);
Q.orders().filterByStatus(OrderStatus.CONFIRMED)
.selectOrderLineList()
.comment("Query orders").purpose("Load data")
.executeForList(ctx);
Q.orders().groupByStatus()
.count()
.comment("Query orders").purpose("Load data")
.executeForList(ctx);
Then ask:
- Is this more readable than what your team writes today?
- Would business-oriented developers understand it?
- Can technical developers customize it without rewriting the architecture?
Use reference models as design material
Do not treat existing models as templates to copy blindly.
Use them as design material for:
- naming conventions,
- aggregate design,
- state modeling,
- service-request patterns,
- API readability targets.
Usually the best path is:
- start from a close reference model,
- remove what does not fit,
- rename aggressively to your real domain terms,
- then add the missing parts.
Common mistake
The most common mistake is choosing a model only because the database tables look similar.
That is too shallow.
A better match is one where:
- the workflow shape is similar,
- the aggregate complexity is similar,
- the reporting and statistics needs are similar,
- the team structure is similar,
- the future customization points are similar.
Next step
After exploring a few models, the next decision is which one is the right starting point.
Continue with How to Choose a Model.