nlqdb

Solve · Solo builders

How do I add a leaderboard to a small product without writing SQL?

If your product needs a leaderboard, a top-N table, or a ranked list and you don't want to author SQL or wire a ranking ORM call, write the goal in English in one `<nlq-data goal="top players by score">` tag — the database, the schema, and the index decisions are all behind the element.

Leaderboards are the canonical "I just need one table and a `ORDER BY DESC LIMIT N`" feature — but indie builders still spend the weekend wiring Postgres, picking an ORM, deciding whether to denormalise, and then making it render. The persona overlap with side projects and hackathon demos is high; the SQL is trivial — the yak-shave isn't.

Drop this in your HTML

The most common indie-product ranking query — `ORDER BY score DESC LIMIT N` — written as the English goal that ships it without an ORM.

> leaderboard scores by region top 5
<nlq-data goal="leaderboard scores by region top 5"></nlq-data>

What nlqdb actually does for this

  • One element renders the ranked table; the engine indexes the sort column automatically based on the workload analyser's observations (`docs/features/engine-migration/FEATURE.md`).
  • Adding the next dimension is an English edit — `"now by region"`, `"now this month only"` — not an ORM rewrite.
  • Anonymous mode ships the leaderboard inside 72h on the free chain; adopt the database to keep it past the window.

What nlqdb doesn't do here

  • No realtime websocket push of rank changes today — the leaderboard refreshes on poll / on user action. Realtime is open in the roadmap; not shipped.
  • No drag-rearrange UI — the element renders a typed table + summary, not a styled leaderboard card. Style it in your own CSS.

Questions buyers ask

Can the leaderboard span multiple regions or shards?
Yes for region-bucketed leaderboards — the demo above shows region as a column. Multi-region replicated writes are not in Phase 1; the database is single-region per tenant (Cloudflare-region of provisioning).
How do I add a new field — say, a player's badge?
Ask in English: `"add a badge column to players"`. The diff (and migration plan) shows under the `SK-ONBOARD-004` confirmation; press Enter to apply. No `ALTER TABLE` written by hand.
Does it scale beyond a hackathon-sized leaderboard?
The Phase 1 engine is Postgres on Neon Free tier (`docs/features/hosted-db-create/FEATURE.md`); single-tenant scales to small-product traffic. The Phase 2 workload analyser proposes a ClickHouse migration when row-count + scan patterns cross the threshold — without an app-side rewrite.
Can my game client write scores via the API?
Yes — `@nlqdb/sdk` (TypeScript), the Go `nlq` CLI, and the Swift Package all speak the same `/v1` wire contract today (Ruby + Rust are placeholders). The `POST /v1/ask` endpoint accepts an English goal; the `POST /v1/run` raw-SQL escape hatch (`GLOBAL-015`) is available when you want to send a parameterised `INSERT` instead.

Where this pain shows up in public

Enduring discussion hubs where you can verify the theme without taking our word for it. We don't quote individual posts; we cite search-result and subreddit URLs that stay live as new threads land.

Try nlqdb in 30 seconds

No sign-in. The anonymous database lasts 72 hours; adopt it with one click if you keep it.

Start with a goal →

Looking at this from a different angle? Browse all solve pages or browse competitor comparisons.