✨ (seaorm): Reexporta IntoActiveModel
This commit is contained in:
parent
9c52873d54
commit
20050e4a67
3 changed files with 10 additions and 8 deletions
|
|
@ -27,7 +27,8 @@
|
||||||
//! - **Transacciones**: [`TransactionTrait`], [`DatabaseTransaction`], [`flatten_txn_err`]
|
//! - **Transacciones**: [`TransactionTrait`], [`DatabaseTransaction`], [`flatten_txn_err`]
|
||||||
//! (para convertir [`TransactionError<E>`] a `E`).
|
//! (para convertir [`TransactionError<E>`] a `E`).
|
||||||
//! - **Modelos activos**: [`ActiveModelTrait`], [`ActiveValue`] ([`ActiveValue::Set`],
|
//! - **Modelos activos**: [`ActiveModelTrait`], [`ActiveValue`] ([`ActiveValue::Set`],
|
||||||
//! [`ActiveValue::Unchanged`], [`ActiveValue::NotSet`]).
|
//! [`ActiveValue::Unchanged`], [`ActiveValue::NotSet`]), [`IntoActiveModel`] (para modificar un
|
||||||
|
//! modelo leído: `model.into_active_model()`).
|
||||||
//! - **Macros de derivación**: [`DeriveEntityModel`], [`DeriveColumn`], [`DerivePrimaryKey`],
|
//! - **Macros de derivación**: [`DeriveEntityModel`], [`DeriveColumn`], [`DerivePrimaryKey`],
|
||||||
//! [`DeriveRelation`], [`EnumIter`].
|
//! [`DeriveRelation`], [`EnumIter`].
|
||||||
//! - **Errores**: [`DbErr`], [`TransactionError`].
|
//! - **Errores**: [`DbErr`], [`TransactionError`].
|
||||||
|
|
@ -167,8 +168,8 @@ pub use sea_orm::prelude::*;
|
||||||
pub use sea_orm;
|
pub use sea_orm;
|
||||||
|
|
||||||
pub use sea_orm::{
|
pub use sea_orm::{
|
||||||
ActiveValue, Condition, DatabaseTransaction, DbBackend, ExecResult, NotSet, Order, QueryOrder,
|
ActiveValue, Condition, DatabaseTransaction, DbBackend, ExecResult, IntoActiveModel, NotSet,
|
||||||
QuerySelect, Set, TransactionError, TransactionTrait, Unchanged,
|
Order, QueryOrder, QuerySelect, Set, TransactionError, TransactionTrait, Unchanged,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Re-exporta `sea_query` para construir sentencias SQL en tiempo de ejecución.
|
/// Re-exporta `sea_query` para construir sentencias SQL en tiempo de ejecución.
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
use pagetop_seaorm::db::{
|
use pagetop_seaorm::db::{
|
||||||
ActiveModelTrait, ActiveValue, ColumnTrait, Condition, EntityTrait, PaginatorTrait,
|
ActiveModelTrait, ActiveValue, ColumnTrait, Condition, EntityTrait, IntoActiveModel,
|
||||||
QueryFilter, Set, dbconn,
|
PaginatorTrait, QueryFilter, Set, dbconn,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::UserStatus;
|
use crate::account::UserStatus;
|
||||||
|
|
@ -61,7 +61,7 @@ pub async fn login(
|
||||||
// Actualizar last_login_at y resetear contador de fallos.
|
// Actualizar last_login_at y resetear contador de fallos.
|
||||||
let user_id = user_model.id;
|
let user_id = user_model.id;
|
||||||
let needs_rehash = password::needs_rehash(&user_model.password_hash);
|
let needs_rehash = password::needs_rehash(&user_model.password_hash);
|
||||||
let mut active: user::ActiveModel = user_model.into();
|
let mut active = user_model.into_active_model();
|
||||||
active.last_login_at = Set(Some(now));
|
active.last_login_at = Set(Some(now));
|
||||||
active.last_access_at = Set(Some(now));
|
active.last_access_at = Set(Some(now));
|
||||||
active.failed_login_count = Set(0);
|
active.failed_login_count = Set(0);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
use pagetop_seaorm::db::{
|
use pagetop_seaorm::db::{
|
||||||
ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, QueryFilter, Set, dbconn,
|
ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, Set,
|
||||||
|
dbconn,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::entity::user_token;
|
use crate::entity::user_token;
|
||||||
|
|
@ -116,7 +117,7 @@ pub async fn consume_token(token: &str, kind: TokenKind) -> Result<i32, AuthErro
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_id = row.user_id;
|
let user_id = row.user_id;
|
||||||
let mut active: user_token::ActiveModel = row.into();
|
let mut active = row.into_active_model();
|
||||||
active.consumed_at = Set(Some(now));
|
active.consumed_at = Set(Some(now));
|
||||||
active.updated_at = Set(now);
|
active.updated_at = Set(now);
|
||||||
active.update(dbconn()).await?;
|
active.update(dbconn()).await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue