← ClaudeAtlas

contentrain-querylisted

Use the @contentrain/query SDK to query Contentrain content with type safety. Use when importing from #contentrain, using QueryBuilder, SingletonAccessor, DictionaryAccessor, DocumentQuery, or CDN client.
Contentrain/ai · ★ 4 · AI & Automation · score 73
Install: claude install-skill Contentrain/ai
# Contentrain Query SDK `@contentrain/query` is a Prisma-pattern generated client that provides type-safe access to Contentrain content. Generated output lives in `.contentrain/client/` — never edit it manually. ## Quick Start ```bash npx contentrain generate # Generate client from models ``` ```typescript import { query, singleton, dictionary, document } from '#contentrain' // Collection const posts = query('blog-post').where('category', 'eq', 'engineering').sort('published_at', 'desc').limit(10).all() // Singleton const hero = singleton('hero').get() // Dictionary const t = dictionary('ui-texts').get() const loginLabel = t['auth.login.button'] // Document const doc = document('blog-post').bySlug('getting-started') ``` ## Runtime API ### QueryBuilder (collections) | Method | Description | |--------|-------------| | `.all()` | Get all entries | | `.first()` | Get first entry | | `.count()` | Return count of matching entries | | `.where(field, value)` | Equality filter (shorthand for `eq`) | | `.where(field, op, value)` | Operator filter: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `contains` | | `.sort(field, direction?)` | Sort (`asc`/`desc`, default `asc`) | | `.limit(n)` | Limit results | | `.offset(n)` | Skip results | | `.include(relation)` | Resolve relation (1 level deep) | ### SingletonAccessor | Method | Description | |--------|-------------| | `.get()` | Get the singleton data | | `.include(relation)` | Resolve relation fields | ### DictionaryAcces