Design models with userItem, itemOf, propertyOf relations and access control
Use this skill when you design or refactor models and relations in a LiveChange service.
For each new model, decide how it relates to the rest of the domain:
userItem – the object belongs to the signed-in user (e.g. user’s device).itemOf – a list of children belonging to a parent model (e.g. device connections).propertyOf – a single state object with the same id as the parent (e.g. cursor state).Choose one main relation; other associations can be plain fields + indexes.
properties clearlytype, default, validation, etc.| Relation | Auto-added field(s) | Auto-added index(es) |
|---|---|---|
itemOf: { what: Device } | device | byDevice |
propertyOf: { what: Device } | device | byDevice |
userItem | user | byUser |
sessionOrUserProperty | sessionOrUserType, sessionOrUser | bySessionOrUser |
propertyOfAny: { to: ['owner'] } | ownerType, owner | byOwner |
Naming convention: parent model name with first letter lowercased (Device → device, CostInvoice → costInvoice). Polymorphic relations add a Type + value pair (e.g. ownerType + owner).
Example:
// ✅ Only define YOUR fields — 'device' is auto-added by itemOf