Komplettumstieg auf drizzle
This commit is contained in:
@@ -2,7 +2,8 @@ import { Body, Controller, Get, Inject, Param, Post, Put } from '@nestjs/common'
|
||||
import { UserService } from './user.service.js';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import { UserEntity } from 'src/models/server.model.js';
|
||||
import { User } from 'src/drizzle/schema.js';
|
||||
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
@@ -18,7 +19,7 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
save(@Body() user: any): Promise<UserEntity> {
|
||||
save(@Body() user: any): Promise<User> {
|
||||
this.logger.info(`Saving user: ${JSON.stringify(user)}`);
|
||||
const savedUser = this.userService.saveUser(user);
|
||||
this.logger.info(`User persisted: ${JSON.stringify(savedUser)}`);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Get, Inject, Injectable, Param } from '@nestjs/common';
|
||||
import { createClient } from 'redis';
|
||||
import { Entity, Repository, Schema } from 'redis-om';
|
||||
import { ListingCriteria, User } from '../models/main.model.js';
|
||||
import { ListingCriteria } from '../models/main.model.js';
|
||||
import { REDIS_CLIENT } from '../redis/redis.module.js';
|
||||
import { UserEntity } from '../models/server.model.js';
|
||||
import { FileService } from '../file/file.service.js';
|
||||
import { User } from 'src/drizzle/schema.js';
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
@@ -30,13 +30,13 @@ export class UserService {
|
||||
// this.userRepository.createIndex();
|
||||
}
|
||||
async getUserById( id:string){
|
||||
const user = await this.userRepository.fetch(id) as UserEntity;
|
||||
const user = await this.userRepository.fetch(id) as User;
|
||||
user.hasCompanyLogo=this.fileService.hasCompanyLogo(id);
|
||||
user.hasProfile=this.fileService.hasProfile(id);
|
||||
return user;
|
||||
}
|
||||
async saveUser(user:any):Promise<UserEntity>{
|
||||
return await this.userRepository.save(user.id,user) as UserEntity
|
||||
async saveUser(user:any):Promise<User>{
|
||||
return await this.userRepository.save(user.id,user) as User
|
||||
}
|
||||
async findUser(criteria:ListingCriteria){
|
||||
return await this.userRepository.search().return.all();
|
||||
|
||||
Reference in New Issue
Block a user