K
Docs
API ReferencePiecesRead from Vault
📖

Read from Vault

base.db.readBase SetVault

Fetches rows from one of your Vault tables. Pick a table, choose which column to match on (like user_id), and give the result a name — it becomes a ✨ Spark you can drop into any later piece.

When to use this
  • Use the Empty path to handle first-time users who don't have a row yet
  • Access a column from the result like {{result.0.coins}} — the 0 means the first row
  • Leave filter empty to read all rows from the table

On the canvas

This is what Read from Vault looks like when you place it on your flow. Each field below is something you configure in the inspector panel.

📖
Read from Vault
base.db.read
Vault
tablerequired
Pick a table…
filterColumn
e.g. user_id
filterValue
e.g. {{user.id}}
asrequired
result
found
empty

Config fields

FieldTypeReqWhat it does
table
Pick a table…
textyesTable 🗄️
filterColumn
e.g. user_id
textFilter column
filterValue
e.g. {{user.id}}
textFilter value
as
result
textyesResult spark ✨

Sparks this piece adds

After this piece runs, these values are available as sparks in every node downstream.

{{result}}arrayAll rows (coins)
{{result.length}}numberNumber of items in result
{{result.0}}objectFirst row (coins)
{{result.0.user_id}}stringFirst item's user_id — text (from coins)
{{result.0.coins}}numberFirst item's coins — integer (from coins)

Output ports

foundTaken when at least one row is found
emptyTaken when no rows match — great for first-timers
📐

In TypeScript, this would be…

Not something you need to write — just a look at what Kitcord does for you.

TypeScript
const rows = await db.all(
  "SELECT * FROM coins WHERE user_id = ?",
  [userId],
);
// {{result}} = rows; {{result.0.coins}} = first row's column
if (rows.length === 0) {
  // Empty port
}

Common patterns

First-time user (empty vault)
TypeScript
const rows = await db.all("SELECT * FROM coins WHERE user_id = ?", [userId]);
if (rows.length === 0) {
  await interaction.reply("You have no score yet — try /earn!");
} else {
  await interaction.reply(`You have ${rows[0].coins} coins!`);
}