Module model

Source
Expand description

Model trait and core database operations

This module provides the main Model trait that enables ORM functionality for structs that derive from it. Features include:

  • Custom Table Names: Use #[table_name("custom")] to override default naming
  • Boolean Type Safety: Automatic conversion between SQLite integers (0/1) and Rust booleans
  • Column Attributes: Customize column properties with #[orm_column(...)]
  • Full CRUD Operations: Create, read, update, delete with type safety

§Examples

use libsql_orm::Model;
use serde::{Serialize, Deserialize};

#[derive(Model, Serialize, Deserialize)]
#[table_name("user_accounts")]  // Custom table name
struct User {
    pub id: Option<i64>,
    pub name: String,
    pub is_active: bool,     // ✅ Automatic boolean conversion
    pub is_verified: bool,   // ✅ Type-safe operations
}

Traits§

Model
Core trait for all database models