K
Docs
Building Bots

🗄️ Vault

Every bot gets its own isolated Vault — a SQLite database that lives on the Engine. Define the schema in your dashboard; the Engine creates or migrates it on every deploy.

🏗️Defining Your Schema

Add tables and columns in the Vault tab. This is what a table looks like:

🗄️
scores
Vault table · 3 columns
user_idPK
TEXT
username
TEXTdefault: ""
points
INTEGERdefault: 0
📐Under the hood — your schema as SQL
TypeScript
// Your Vault schema becomes real SQLite tables:
db.run(`
  CREATE TABLE IF NOT EXISTS scores (
    user_id  TEXT    PRIMARY KEY,  -- type: TEXT, primaryKey
    username TEXT    DEFAULT '',   -- type: TEXT, default ""
    points   INTEGER DEFAULT 0     -- type: INTEGER, default 0
  )
`);
// The Engine applies CREATE TABLE IF NOT EXISTS on every deploy — safe and additive.

📊Column Types

TypeStoresGood for
📝TEXT
String textUser IDs, names, messages, ISO timestamps
🔢INTEGER
Whole numbersCounters, scores, Discord snowflakes
💫REAL
Floating-point numbersAverages, percentages
BOOLEAN
True/false (stored as 0/1)Flags, active/inactive states
📦BLOB
Raw binary dataRarely needed — prefer TEXT

🧩Vault Pieces

Access your Vault from any flow using base.db.* pieces — part of the Base Set.

📖 Read from Vault
📖
Read from Vault
base.db.read
Vault
tablerequired
scores
filterColumn
user_id
filterValue
{{input.user.id}}
asrequired
result
found
empty

Results land in {{result}} — use {{result.0.points}}.

✏️ Write to Vault
✏️
Write to Vault
base.db.write
Vault
tablerequired
scores
upsert
true

Turn on upsert to update existing rows by primary key.

🗑️ Delete from Vault
🗑️
Delete from Vault
base.db.delete
Vault
tablerequired
scores
filterColumn
user_id
filterValue
{{input.user.id}}

Always set a filter — without one, the entire table is wiped.

📐Naming Rules

Table and column names must be lowercase snake_case — letters, digits, underscores only. Must start with a letter.

✅ Valid
scores
user_data
message_log
ban_records
❌ Invalid
UserScores (uppercase)
1scores (starts digit)
my-table (hyphen)

🚀Schema on Deploy

New tableCreated automatically
New column on existing tableAdded (with default if specified)
Removed table or columnLeft intact — data is never dropped automatically
⚠️Data is never dropped automatically

Removing a table or column from your schema leaves the data in SQLite. To remove data, use Delete from Vault explicitly.