Usage In StartupJS
StartupJS uses TeamPlay as its signal and ORM layer. In StartupJS apps, use the same model conventions as TeamPlay, but import app-facing APIs from startupjs.
For the full model convention, read ORM. For generated types and Signal<T> examples, read TypeScript Support.
Imports
Import TeamPlay APIs through StartupJS:
Use direct teamplay imports only for low-level integration code.
Models Folder
StartupJS loads file-based models automatically. Use models/:
StartupJS still supports the legacy model/ folder as a fallback. If that fallback is used, TeamPlay prints a warning asking you to migrate to models/.
The same loader also generates teamplay-env.d.ts. npx startupjs check runs that generator before typechecking.
Pure TeamPlay apps use a manual models.setup.ts file. StartupJS apps should not create one for the same models because the StartupJS registry already imports file-based models, merges plugin models, and initializes TeamPlay.
Schema
StartupJS commonly uses TeamPlay's simplified schema format, where the top-level object is the document fields. If you write full JSON Schema, use type: 'object' at the root and put fields under properties.
Collection Model
Document Model
React Components
Wrap components in observer() and subscribe to database data with useSub():
Pass signals to child components instead of raw values:
Signal<Task> includes schema fields and document model methods when Task maps to one known collection.
Subscriptions Outside React
Use sub() outside React:
Private client state such as $._session is local and does not need subscriptions.
Access Rules And Aggregations
Enable server features in startupjs.config.js when you need them:
Access rules live in models/<collection>/access.ts; aggregation files are named _name.ts. See Access Control and Aggregations for examples.
Typechecking
Use StartupJS' checker:
It runs a pug-aware TypeScript language service and generates teamplay-env.d.ts before checking. Plain tsc --noEmit does not understand StartupJS pug templates.
For normal validation, run: