objectstack-ai/framework/objectstack-query

Claude Code and agent skill by objectstack-ai/framework

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Construct ObjectQL queries — filters, sorting, pagination, aggregation, relation expansion, and full-text search. Use when the user is writing a query DSL expression or picking a pagination strategy. Do not use for defining objects / fields / relationships (see objectstack-data), for designing the API endpoint that exposes a query (see objectstack-api), or for a list view's filter rules / dashboard datasets (see objectstack-ui).

Install

npx vskill@latest install objectstack-ai/framework/objectstack-query

SKILL.md

Query Design — ObjectStack Query DSL

Calling Convention — object is the FIRST ARGUMENT

SurfaceShapeLegal option keys
engine find / findOneengine.find('task', {…}, { context })context, where, fields, orderBy, limit, offset, search, searchFields, expand — plus the driver passthrough keys transaction, tenantId, tenantIds, timezone, bypassTenantAudit, preserveAudit
engine aggregateengine.aggregate('deal', {…})context, where, groupBy, aggregations, having, timezone, search, searchFields — the two search keys filter the input rows before grouping, AND-ed with where, exactly as on find
engine countengine.count('task', {…})context, where
protocol / RESTfindData({ object: 'task', query: {…} })object sits OUTSIDE the query
nested expand valuea QueryAST — { object, fields, where }(see Expand)

ENGINE_FIND_OPTION_KEYS / ENGINE_AGGREGATE_OPTION_KEYS are closed sets: a key outside the row is refused by name (find('task') does not recognise option 'bogus'), never ignored. A standalone { object: 'account', limit: 20 } literal is therefore a `QueryAST` — legal as findData's query or an expand value — not an engine option bag. top folds to limit, filter to where, before that check.

The passthrough six ride along on find/findOne (and on update/delete) because there the option bag IS the base of the driver options, which is how an explicit tenantId reaches the driver. count and aggregate never forward the bag, so on those two the same keys are deliberately ILLEGAL — accepting them would be the silently-ignored option this check exists to close. The one exception is timezone: aggregate reads it itself, for date bucketing, so it is legal there and the row above lists it; count refuses it with the rest.

Which filter dialect?
Writing…DialectOwner
an ObjectQL wherethe $ operators belowthis skill
a list view / nav-item filter[{ field, operator, value }] over the 20-operator VIEW_FILTER_OPERATORS enum (equals, icontains, is_null, before, between, …) — unknown operators are refused at parseobjectstack-ui
a dataset measure filterthe measure's own filterobjectstack-ui

Execution Context (context)

The RLS / system-read escape hatch. A hook, job or endpoint that reads without one runs as whatever identity the caller carried — org-scoping hooks then return fewer rows, indistinguishable from "there is no data".

typescript
const SYS = { isSystem: true } as const;
const [row] = await engine.find('project', { where: { name }, limit: 1, context: SYS });

Pass any SUBSET of the execution envelope (identity, tenant, transaction): { isSystem: true } for a system read, otherwise the caller's own context (user, position or permission set), or 403 PERMISSION_DENIED (ADR-0096 D5). On the READ methods it may sit in the query bag (above) OR in the trailing options argument, engine.find(obj, query, { context }); the trailing one wins when both are given. Writes take only the trailing argument.

Removed Keys → Live Replacement

Removed keyLive replacement
query.cursorkeyset paging — where on the sort key + orderBy + limit
query.joinsexpand (display), or { relation: { field: value } } in where (filter)
query.distinctgroupBy the fields — each unique combination is one row
query.windowFunctionsreport/dashboard metadata (objectstack-ui), or rank / accumulate in app code
aggregation distinct: truecount_distinct
aggregation array_agg / string_aggnone — read the rows with fields and shape them in the caller, or materialise the roll-up as a stored field

All six are tombstoned in @objectstack/spec 17: tsc types them never, and a query carrying one fails to parse with the upgrade prescription. The retirement procedure and the full tombstone register are objectstack-upgrade.

Quick Reference — Detailed Rules

  • [Filters](./rules/filters.md) — all operators, logical combinations, filtering by a related record, now-anchored comparands, date macros and session tokens
  • [Aggregation](./rules/aggregation.md) — groupBy, date bucketing, functions, having, per-measure filter
  • [Pagination](./rules/pagination.md) — offset vs keyset, best practices, performance

Filter Operators

Implicit Equality (Shorthand)

The simplest filter — field equals value:

typescript
{ where: { status: 'active' } }
// SQL: WHERE status = 'active'
Comparison Operators
OperatorPurposeSQL EquivalentTypes
$eqEqual=Any
$neNot equal<>Any
$gtGreater than>Number, Date
$gteGreater than or equal>=Number, Date
$ltLess than<Number, Date
$lteLess than or equal<=Number, Date
typescript
{ where: { age: { $gte: 18 } } }
// SQL: WHERE age >= 18
Set & Range Operators
OperatorPurposeSQL Equivalent
$inIn listIN (...)
$ninNot in listNOT IN (...)
$betweenInclusive rangeBETWEEN ? AND ?
typescript
{ where: { status: { $in: ['active', 'pending'] } } }
{ where: { amount: { $between: [100, 500] } } }
String Operators
OperatorPurposeSQL Equivalent
$containsContains substringLIKE '%?%'
$notContainsDoes not containNOT LIKE '%?%'
$startsWithStarts with prefixLIKE '?%'
$endsWithEnds with suffixLIKE '%?'
$icontainsContains, case-blindLIKE '%?%' folded
$likeWhole-value pattern, caller binds % / _LIKE ?
$ilike$like, case-blindILIKE ?

$contains / $notContains / $startsWith / $endsWith compare CASE-SENSITIVELY; $icontains is the case-INSENSITIVE twin (ASCII folding only). So the user-facing cases want $icontains:

typescript
{ where: { email: { $icontains: '@company.com' } } }

Full table, $like portability and the $ilike boundary: [filter rules](./rules/filters.md).

Null & Existence Operators
OperatorPurposeSQL / NoSQL
$nullIs null checkIS NULL / IS NOT NULL
$existsHas a valueIS NOT NULL / IS NULL
$emptyIs empty by the field's declared typeIS NULL, plus '' (text types) or [] (multi-value)
typescript
{ where: { deleted_at: { $null: true } } }
{ where: { notes: { $empty: true } } } // false = has content

A view filter's is_empty / is_not_empty lowers to $empty. A face that judges by declared type refuses it on a column it holds no declaration for (the built-in id, for one) — use $null there.

Logical Operators

Combine conditions with $and, $or, and $not:

typescript
// OR: active accounts OR accounts with high revenue
{ where: { $or: [{ status: 'active' }, { revenue: { $gt: 1000000 } }] } }
// AND + OR combined
{
where: {
$and: [
{ type: 'enterprise' },
{ $or: [{ region: 'us' }, { region: 'eu' }] },
]
}
}
// NOT: exclude closed accounts
{ where: { $not: { status: 'closed' } } }
Filtering by a related record

{ customer: { country: 'US' } } beneath a lookup is served in where: the engine reads the related object as the caller and matches its ids. The limits (one level, forward only, where only, 1000 ids, the caller's permissions) and the two-step route past them: [filter rules → Relation Filters](./rules/filters.md).

Cross-field comparisons

{ $field: '...' } compares two columns of the same row, in a comparison position only; { $now: true, addDays: OFFSET } is the instant the query runs at, shifted by whole days a number field of the record holds — see [filter rules → Field References / Now-Anchored Comparands](./rules/filters.md).

Sorting

Sort with orderBy — an array of sort nodes:

typescript
{
object: 'account',
orderBy: [
{ field: 'priority', order: 'desc' },
{ field: 'name', order: 'asc' }, // Secondary sort
]
}

Rules:

  • Order of array elements defines sort priority
  • Default order is 'asc' — you can omit it for ascending sorts
  • Sort fields should be indexed for performance (see objectstack-data indexing rules)

Pagination

typescript
// Offset paging — page 3
{ object: 'account', limit: 20, offset: 40 }

When to use: UI pages, small datasets, "jump to page N". It degrades on large offsets — the database still scans the skipped rows.

For keyset paging (infinite scroll, APIs, large datasets, real-time feeds), filter past the last row you saw with a where on the sort key, and always orderBy that same field in that same direction — the pattern, the direction rule and the pitfalls are [pagination rules](./rules/pagination.md).

Aggregation

The functions (count, sum, avg, min, max, count_distinct), date bucketing, having, and the per-measure filter are [aggregation rules](./rules/aggregation.md). The call shape:

typescript
// Total revenue per region
const rows = await engine.aggregate('deal', {
groupBy: ['region'],
aggregations: [
{ function: 'sum', field: 'amount', alias: 'total_revenue' },
{ function: 'count', alias: 'deal_count' },
],
});
// SQL: SELECT region, SUM(amount) AS total_revenue, COUNT(*) AS deal_count
// FROM deal GROUP BY region

fields and orderBy are NOT in ENGINE_AGGREGATE_OPTION_KEYS — do not put them in an aggregate bag. Grouped fields are auto-selected into the result rows; read each measure under its alias, and reference that same name from having. groupBy entries may be objects for date bucketing — { field: 'closed_at', dateGranularity: 'quarter' }.

Expand (Related Records)

Load related records through lookup / master_detail fields. Keep the foreign key in `fields` — the relation is carried by that column:

typescript
const tasks = await engine.find('task', {
fields: ['title', 'status', 'assignee', 'project'], // the FK columns stay
expand: {
assignee: { object: 'user', fields: ['name', 'email'] },
project: {
object: 'project',
fields: ['name'],
expand: { org: { object: 'org', fields: ['name'] } }, // nested expand
},
},
});

Rules:

  • The projection must RETAIN the foreign-key column. fields: ['title']

with expand: { project: … } resolves nothing: the engine reads the FK off each record and skips the relation when it is absent, so the call returns rows with no related data and no error.

  • Max expand depth is 3 by default
  • The engine resolves expands via batch $in queries (not N+1)
  • Keys in expand must be lookup or master_detail field names
  • Each expand value is a nested QueryAST, but the engine applies **select

(fields) and filter (where) only** — per-parent limit / offset / orderBy are NOT applied on this path. To paginate or sort related records, query the related object directly.

Full-Text Search

The canonical form is a bare string with a sibling searchFields:

typescript
const rows = await engine.find('article', {
search: 'machine learning',
searchFields: ['title', 'content'],
limit: 10,
});
// Executes as:
// { $and: [
// { $or: [{ title: { $icontains: 'machine' } }, { content: { $icontains: 'machine' } }] },
// { $or: [{ title: { $icontains: 'learning' } }, { content: { $icontains: 'learning' } }] },
// ]}

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 93 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
14
Repository forks
6
7-day trend score
14

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 26 Jul 2026, 3 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/objectstack-ai/framework/objectstack-query/badge)](https://verified-skill.com/skills/objectstack-ai/framework/objectstack-query)

Something wrong with this skill or its page? Tell us.