Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/33722-skills-data-hooks-owner-id-filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/skills': patch
---

docs(skills): the data-hooks query example filters on the injected `owner_id`, not a hand-named `owner`

Clause-②: no
Metadata-protocol: none

The `ctx.api.object(name)` query-shape example in objectstack-data's `references/data-hooks.md` now filters `task` on `{ owner_id: uid }`. The old `{ owner: uid }` named a field the object does not have unless an author hand-adds a second owner beside the injected one; on an object without it the query is refused with `400 INVALID_FILTER`. The objectstack-data eval about a required `user` field with `deleteBehavior: 'restrict'` now names that field `reviewer`, a role apart from the record owner, instead of an `owner` field that holds the ticket.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
},
{
"id": 6,
"prompt": "On `ticket`, `owner` is the agent who holds it and must always be set; deleting that agent's user account must be blocked while they still hold tickets. `watchers` is several users, and a deleted user should just drop out of the list.",
"expected_output": "Both are `type: 'user'` fields, each with an authored `deleteBehavior` — a `user` field joins the referential delete walk only when it declares one. `owner`: `required: true` with `deleteBehavior: 'restrict'` (deleting a held user is refused with `409 DELETE_RESTRICTED`; `set_null` on a required field would refuse too). `watchers`: `multiple: true` with `deleteBehavior: 'set_null'` (only the deleted member is removed; an emptied set is `[]`). Neither is a `lookup` to a `user` object, which does not exist, and a `user` field with no `deleteBehavior` keeps the deleted user's id.",
"prompt": "On `ticket`, `reviewer` is the lead who signs it off and must always be set; deleting that lead's user account must be blocked while they still review tickets. `watchers` is several users, and a deleted user should just drop out of the list.",
"expected_output": "Both are `type: 'user'` fields, each with an authored `deleteBehavior` — a `user` field joins the referential delete walk only when it declares one. `reviewer`: `required: true` with `deleteBehavior: 'restrict'` (deleting a named reviewer is refused with `409 DELETE_RESTRICTED`; `set_null` on a required field would refuse too). `watchers`: `multiple: true` with `deleteBehavior: 'set_null'` (only the deleted member is removed; an emptied set is `[]`). Neither is a `lookup` to a `user` object, which does not exist, and a `user` field with no `deleteBehavior` keeps the deleted user's id.",
"files": [],
"assertions": {
"must_contain": [
Expand Down
2 changes: 1 addition & 1 deletion skills/objectstack-data/references/data-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ same DSL as the [objectstack-query](../../objectstack-query/SKILL.md) skill:
await ctx.api.object('candidate').findOne({ where: { id: ctx.result.id } });
await ctx.api.object('candidate').find({ where: { stage: 'hired' } });
await ctx.api.object('invoice').count({ where: { amount: { $gte: 1000 } } });
await ctx.api.object('task').find({ where: { $and: [{ done: false }, { owner: uid }] } });
await ctx.api.object('task').find({ where: { $and: [{ done: false }, { owner_id: uid }] } });
```

> `filter:` is tolerated as an **object-valued** alias (normalised to `where`),
Expand Down
Loading