🎨 (seaorm): Mejora API y documentación
- Reescribe la documentación con ejemplos completos, guía rápida y tablas de referencia. - Renombra `connection()` a `dbconn()`. - Añade `execute()` para SQL en crudo y corrige `fetch_all`/`fetch_one` para aceptar `&Q` en lugar de `&mut Q`. - Cambia `futures::executor::block_on` por `tokio::task::block_in_place` para compatibilidad con el *runtime* multi-hilo. - Los fallos de migración al arrancar provocan `panic!` en lugar de log de error silencioso. - Actualiza `#[pagetop::test]` para usar `flavor = "multi_thread"`, alineándolo con `#[pagetop::main]` y con las extensiones que usan SeaORM.
This commit is contained in:
parent
dfc1bdbc4c
commit
830602b24e
9 changed files with 602 additions and 178 deletions
|
|
@ -1,13 +1,14 @@
|
|||
//! Adaptación de <https://github.com/loco-rs/loco/blob/master/src/schema.rs>
|
||||
//! Adapted from <https://github.com/loco-rs/loco/blob/master/src/schema.rs>
|
||||
//!
|
||||
//! # Ayudantes de esquema de base de datos
|
||||
//! # Database Table Schema Helpers
|
||||
//!
|
||||
//! Define funciones y ayudantes para crear esquemas de tablas usando `sea-orm` y `sea-query`.
|
||||
//! This module defines functions and helpers for creating database table
|
||||
//! schemas using the `sea-orm` and `sea-query` libraries.
|
||||
//!
|
||||
//! # Ejemplo
|
||||
//! # Example
|
||||
//!
|
||||
//! El siguiente ejemplo muestra cómo escribir un archivo de migración usando los ayudantes
|
||||
//! de esquema.
|
||||
//! The following example shows how the user migration file should be and using
|
||||
//! the schema helpers to create the Db fields.
|
||||
//!
|
||||
//! ```rust
|
||||
//! use pagetop_seaorm::migration::*;
|
||||
|
|
@ -597,7 +598,7 @@ pub fn array_uniq<T: IntoIden>(col: T, elem_type: ColumnType) -> ColumnDef {
|
|||
array(col, elem_type).unique_key().take()
|
||||
}
|
||||
|
||||
/// Añade las columnas de timestamp (`CreatedAt` y `UpdatedAt`) a una tabla existente.
|
||||
/// Add timestamp columns (`CreatedAt` and `UpdatedAt`) to an existing table.
|
||||
pub fn timestamps(t: TableCreateStatement) -> TableCreateStatement {
|
||||
let mut t = t;
|
||||
t.col(timestamp(GeneralIds::CreatedAt).default(Expr::current_timestamp()))
|
||||
|
|
@ -605,7 +606,7 @@ pub fn timestamps(t: TableCreateStatement) -> TableCreateStatement {
|
|||
.take()
|
||||
}
|
||||
|
||||
/// Crea un alias.
|
||||
/// Create an Alias.
|
||||
pub fn name<T: Into<String>>(name: T) -> Alias {
|
||||
Alias::new(name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue