Skip to content

Export

The alab export command generates native, type-safe structures from your schema.

Terminal window
alab export -f <rust, go, python, typescript, openapi, graphql, all>
schemas/auth/user.js
export default table({
id: col.id(),
username: col.string(50).unique(),
bio: col.text().optional(),
age: col.integer().optional(),
score: col.float().optional(),
balance: col.decimal(19, 4).default(0),
is_active: col.boolean().default(true),
birthdate: col.date().optional(),
login_time: col.time().optional(),
last_seen: col.datetime().optional(),
external_id: col.uuid().optional(),
settings: col.json().optional(),
avatar: col.base64().optional(),
role: col.enum(["admin", "editor", "viewer"]).default("viewer"),
}).timestamps();
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum AuthUserRole {
Admin,
Editor,
Viewer,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuthUser {
pub age: Option<i32>,
pub avatar: Option<Vec<u8>>,
pub balance: String,
pub bio: Option<String>,
pub birthdate: Option<NaiveDate>,
pub external_id: Option<String>,
pub id: String,
pub is_active: bool,
pub last_seen: Option<DateTime<Utc>>,
pub login_time: Option<NaiveTime>,
pub role: AuthUserRole,
pub score: Option<f32>,
pub settings: Option<serde_json::Value>,
pub username: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}

💡 Why are Decimals strings?

Balances are exported as strings in all languages to preserve financial precision. By exporting a string, alab lets you choose your favorite precision library (like decimal.Decimal in Python, or rust_decimal in Rust) to handle the math.