Skip to content

Commit 2a8b7ac

Browse files
os-zhuangclaude
andauthored
docs: document the user field type (#2352)
Follow-up to #2351 (the `user` field type). Brings the docs in line with the shipped feature: - references/data/field.mdx + seed-loader.mdx — regenerated (`gen:docs`) so the FieldType / reference enums list `user` (the merge added the type but didn't regenerate these committed reference pages). - guides/data-modeling.mdx — new "User Fields" section: `Field.user()`, `multiple`, `defaultValue: 'current_user'`, and that it's a lookup specialized to sys_user (stored as an FK, zero-migration from `Field.lookup('sys_user')`). - guides/standards.mdx — adds a User/Person row to the field-type selection table. Only the user-related regenerated lines are included; unrelated generated-doc drift was intentionally left out. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d980f0d commit 2a8b7ac

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

content/docs/guides/data-modeling.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,32 @@ Field.lookup('contact', {
263263
})
264264
```
265265

266+
### User Fields
267+
268+
Pick a person — the equivalent of Airtable's *Collaborator* or Salesforce's
269+
`Lookup(User)`. A `user` field is a **lookup specialized to the built-in
270+
`sys_user` object**: it stores the user's id (a real foreign key), resolves to
271+
the user's name/avatar via `$expand`, and renders as a searchable people picker.
272+
You never reference `sys_user` by hand.
273+
274+
```typescript
275+
// Single assignee
276+
Field.user({ label: 'Assignee' })
277+
278+
// Collaborators / watchers (multiple)
279+
Field.user({ label: 'Watchers', multiple: true })
280+
281+
// Auto-fill the acting user on create (record owner / reporter)
282+
Field.user({ label: 'Owner', defaultValue: 'current_user' })
283+
```
284+
285+
`defaultValue: 'current_user'` stamps the authenticated user's id at insert time
286+
(the people-field counterpart to `'NOW()'` for timestamps). Because a `user`
287+
field is stored exactly like a lookup, an existing `Field.lookup('sys_user')`
288+
is equivalent at the storage layer — adopt `Field.user()` with no data
289+
migration. Record ownership and row-level security continue to use the existing
290+
`owner_id` convention.
291+
266292
### Address Field
267293

268294
Structured address data:

content/docs/guides/standards.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export const MyObject = ObjectSchema.create({
146146
| Choice | `Field.select()` | Status, category, type |
147147
| Multiple choice | `Field.select({ multiple: true })` | Tags, skills |
148148
| Reference | `Field.lookup()` | Relationships |
149+
| User / Person | `Field.user()` | Assignee, owner, collaborators (picks a `sys_user`) |
149150
| Location | `Field.location()` | GPS coordinates |
150151
| Address | `Field.address()` | Mailing addresses |
151152
| Color | `Field.color()` | Brand colors, themes |

content/docs/references/data/field.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const result = Address.parse(data);
120120
* `lookup`
121121
* `master_detail`
122122
* `tree`
123+
* `user`
123124
* `image`
124125
* `file`
125126
* `avatar`

content/docs/references/data/seed-loader.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Describes how a field reference is resolved during seed loading
9494
| **field** | `string` || Source field name containing the reference value |
9595
| **targetObject** | `string` || Target object name (snake_case) |
9696
| **targetField** | `string` || Field on target object used for matching |
97-
| **fieldType** | `Enum<'lookup' \| 'master_detail'>` || Relationship field type |
97+
| **fieldType** | `Enum<'lookup' \| 'master_detail' \| 'user'>` || Relationship field type |
9898

9999

100100
---

0 commit comments

Comments
 (0)