Initial Nuxt data explorer setup

This commit is contained in:
2025-09-29 14:10:11 -06:00
commit 47f4a20bd3
35 changed files with 13509 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import type { ParsedQuery } from '../data-sources/types'
type PostgrestOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike'
export function applyParsedQuery(builder: any, parsed: ParsedQuery | null) {
if (!parsed) {
return builder
}
for (const filter of parsed.filters) {
const operator: PostgrestOperator = (filter.operator ?? 'eq') as PostgrestOperator
if (typeof builder[operator] === 'function') {
const value = operator === 'like' || operator === 'ilike' ? String(filter.value) : filter.value
builder = builder[operator](filter.field, value)
}
}
if (parsed.orderBy && typeof builder.order === 'function') {
builder = builder.order(parsed.orderBy.field, {
ascending: parsed.orderBy.ascending !== false
})
}
if (parsed.limit && parsed.offset !== undefined && typeof builder.range === 'function') {
const from = parsed.offset
const to = parsed.offset + parsed.limit - 1
builder = builder.range(from, to)
} else if (parsed.limit && typeof builder.limit === 'function') {
builder = builder.limit(parsed.limit)
}
return builder
}