Skip to content

Commit faf500b

Browse files
committed
no-mistakes(document): docs(projection): clarify when to omit @fields on projection identities
1 parent 4183cc6 commit faf500b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎docs/features/source-kinds.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ owning entity's own columns, declare it as an `object.projection`, not an `objec
124124
present, MUST extend an entity identity; the example below omits it (a keyless read
125125
model).
126126

127+
> **Projection identities and the `@fields` attribute.** When a projection declares an
128+
> identity by extending an entity's identity, the `@fields` attribute is optional. When
129+
> omitted, the loader derives the identity key from the projection's fields that pass
130+
> through the base identity's key field(s). When a projection passes the key through on a
131+
> renamed field, omitting `@fields` (the recommended form) lets the loader automatically
132+
> compute the key — if you instead declare `@fields` explicitly and name a different field,
133+
> the declaration is honored but diverges from what the key actually is. Use the derived
134+
> form (omit `@fields`) whenever the projection's key field is derived from or passed
135+
> through from the base identity, and use explicit `@fields` only when the key is redefined
136+
> to an unrelated field.
137+
127138
**The view's SQL is generated — never hand-write it.** The `CREATE VIEW` body is
128139
derived from the projection's `origin.*` children (passthrough columns, aggregates,
129140
collections) and emitted by the Node `meta migrate` (schema migrations are Node-owned

0 commit comments

Comments
 (0)