feat: initialize thoughts-frontend with Next.js, TypeScript, and ESLint
- Add ESLint configuration for Next.js and TypeScript support. - Create Next.js configuration file with standalone output option. - Initialize package.json with scripts for development, build, and linting. - Set up PostCSS configuration for Tailwind CSS. - Add SVG assets for UI components. - Create TypeScript configuration for strict type checking and module resolution.
This commit is contained in:
28
thoughts-backend/app/src/persistence/user.rs
Normal file
28
thoughts-backend/app/src/persistence/user.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DbConn, DbErr, EntityTrait, QueryFilter, Set};
|
||||
|
||||
use models::domains::user;
|
||||
use models::params::user::CreateUserParams;
|
||||
use models::queries::user::UserQuery;
|
||||
|
||||
pub async fn create_user(
|
||||
db: &DbConn,
|
||||
params: CreateUserParams,
|
||||
) -> Result<user::ActiveModel, DbErr> {
|
||||
user::ActiveModel {
|
||||
username: Set(params.username),
|
||||
..Default::default()
|
||||
}
|
||||
.save(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn search_users(db: &DbConn, query: UserQuery) -> Result<Vec<user::Model>, DbErr> {
|
||||
user::Entity::find()
|
||||
.filter(user::Column::Username.contains(query.username.unwrap_or_default()))
|
||||
.all(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_user(db: &DbConn, id: i32) -> Result<Option<user::Model>, DbErr> {
|
||||
user::Entity::find_by_id(id).one(db).await
|
||||
}
|
Reference in New Issue
Block a user