🥇
Find Rank
vault.rankThe VaultVaultFinds one row's place when the table is sorted by a column — without fetching the whole leaderboard. Ties share a place, like a real scoreboard. Gives you {{rank.place}}, {{rank.total}} and {{rank.value}}.
When to use this
- →Two people on the same score share a place — the next one skips ahead (#3, #3, #5)
- →{{rank.total}} counts every row in the table
On the canvas
This is what Find Rank looks like when you place it on your flow. Each field below is something you configure in the inspector panel.
🥇Vault
Find Rank
vault.ranktablerequired
Pick a table…
columnrequired
e.g. xp
order
select…
keyrequired
{{input.user.id}}
asrequired
rank
found
missing
Config fields
| Field | Type | Req | What it does |
|---|---|---|---|
tablePick a table… | text | yes | Table 🗄️ |
columne.g. xp | text | yes | Rank by 🏆 |
order | select | — | Which way 🔃 |
key{{input.user.id}} | text | yes | Whose rank 🔑 |
asrank | text | yes | Save it as ✨ |
Output ports
foundTheir row exists — {{rank.place}} is their spot
missingThey don't have a row yet
📐
In TypeScript, this would be…
Not something you need to write — just a look at what Kitcord does for you.
TypeScript
const mine = await db.get("SELECT xp FROM levels WHERE user_id = ?", [userId]);
const ahead = await db.get("SELECT COUNT(*) AS n FROM levels WHERE xp > ?", [mine.xp]);
const total = await db.get("SELECT COUNT(*) AS n FROM levels");
// {{rank.place}} = ahead.n + 1, {{rank.total}} = total.n, {{rank.value}} = mine.xpRelated pieces
More Vault pieces