Added more paralization to allow better multi-user perfomace
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2
|
||||
|
||||
use chacha20poly1305::{aead::Aead, AeadCore, ChaCha20Poly1305, KeyInit};
|
||||
use futures::{Stream, StreamExt};
|
||||
use pbkdf2::pbkdf2_hmac_array;
|
||||
use rand::{rngs::OsRng, RngCore};
|
||||
use sea_orm::{prelude::*, ActiveValue::Set, QuerySelect};
|
||||
@ -88,14 +89,18 @@ impl Model {
|
||||
|
||||
impl Entity {
|
||||
/// Gets a list of account names of a user
|
||||
pub async fn get_names(user_id: u64, db: &DatabaseConnection) -> crate::Result<Vec<String>> {
|
||||
Self::find()
|
||||
pub async fn get_names(
|
||||
user_id: u64,
|
||||
db: &DatabaseConnection,
|
||||
) -> crate::Result<impl Stream<Item = crate::Result<String>> + '_> {
|
||||
let result = Self::find()
|
||||
.select_only()
|
||||
.column(Column::Name)
|
||||
.filter(Column::UserId.eq(user_id))
|
||||
.into_tuple()
|
||||
.all(db)
|
||||
.await
|
||||
.map_err(|err| err.into())
|
||||
.stream(db)
|
||||
.await?
|
||||
.map(|item| item.map_err(Into::into));
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user