Skip to main content

Module query_builder

Module query_builder 

Source
Expand description

Fluent query builder for Eloquent-like API

Provides a chainable query interface that uses the global DB connection.

§Example

use ferro_rs::models::todos::{Todo, Column};

// Simple query
let todos = Todo::query().all().await?;

// With filters
let todo = Todo::query()
    .filter(Column::Title.eq("test"))
    .filter(Column::Id.gt(5))
    .first()
    .await?;

// With ordering and pagination
let todos = Todo::query()
    .order_by_desc(Column::CreatedAt)
    .limit(10)
    .offset(20)
    .all()
    .await?;

// With eager loading (avoids N+1)
let (animals, shelters) = Animal::query()
    .all_with(|animals| async {
        Shelter::batch_load(animals.iter().map(|a| a.shelter_id)).await
    })
    .await?;

Structs§

QueryBuilder
Fluent query builder wrapper