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
8 changes: 8 additions & 0 deletions .changeset/33730-skills-query-hook-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@objectstack/skills': patch
---

Clause-②: no
Metadata-protocol: none

The published query and hook skill examples now filter on the platform's `owner_id` column with `{current_user_id}`, and the hook `find` example reads the caller's id from `ctx.session?.userId` instead of an unbound variable.
2 changes: 2 additions & 0 deletions skills/objectstack-data/references/data-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ 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 } } });
const uid = ctx.session?.userId;
if (!uid) return;
await ctx.api.object('task').find({ where: { $and: [{ done: false }, { owner_id: uid }] } });
```

Expand Down
5 changes: 2 additions & 3 deletions skills/objectstack-query/rules/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ where: {
period boundaries like `{current_month_start}`, `{last_quarter_end}`,
`{next_year_start}` (and bare aliases like `{month_start}`).
- **Parameterised tokens:** `{N_<unit>_ago}` / `{N_<unit>_from_now}` with
units `minute|hour|day|week|month|year` — e.g. `{30_days_ago}`,
`{2_weeks_from_now}`.
units `minute|hour|day|week|month|year` — e.g. `{2_weeks_from_now}`.
- **Both spellings parse:** `{today}` and `${today}` are the same token
(`DATE_MACRO_WRAPPED_RE` is `/^\$?\{([a-zA-Z0-9_]+)\}$/`, and the context
tokens share it).
Expand All @@ -174,7 +173,7 @@ where: {
user's id and the active organization id.

```typescript
where: { owner: '{current_user_id}', close_date: { $gte: '{current_year_start}' } }
where: { owner_id: '{current_user_id}', close_date: { $gte: '{current_year_start}' } }
```

**Scope:** tokens expand on **both** sides of the wire — client-side by
Expand Down
Loading