Modifiers
Modifiers shape the result: ordering, pagination, and response format.
Reference
| Method | Effect |
|---|---|
.order(col, { ascending }) | Sort results |
.limit(n) | Return at most n rows |
.range(from, to) | Slice rows by index (0-based, inclusive) |
.single() | Expect exactly one row — errors if 0 or 2+ |
.maybeSingle() | Return one row or null — errors only if 2+ |
.count('exact' | 'planned' | 'estimated') | Include row count in response |
Examples
// Paginate — page 2, 20 items per pageawait massi .from('posts') .select('*') .order('created_at', { ascending: false }) .range(20, 39)
// Expect exactly one rowconst { data: post, error } = await massi .from('posts') .select('*') .eq('id', postId) .single()// data is Post (not Post[]), error is set if not found
// Count without fetching rowsconst { count } = await massi .from('posts') .select('*', { count: 'exact', head: true })Notes
.single()setsPrefer: return=representationand validates the count. If you get an error like"JSON object requested, multiple (or no) rows returned", your filter isn’t specific enough..range()sendsRange: from-toand returns a206 Partial Contentresponse. Use it for all paginated UIs.