added Get api for some table
This commit is contained in:
parent
2c02ad8d06
commit
bc7b4cd272
@ -8,19 +8,19 @@ export class ConversationsController {
|
||||
constructor(private readonly conversationsService: ConversationsService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createConversationDto: CreateConversationDto) {
|
||||
return this.conversationsService.create(createConversationDto);
|
||||
async create(@Body() createConversationDto: CreateConversationDto) {
|
||||
return await this.conversationsService.create(createConversationDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.conversationsService.findAll();
|
||||
async findAll() {
|
||||
return await this.conversationsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.conversationsService.findOne(+id);
|
||||
}
|
||||
// @Get(':id')
|
||||
// findOne(@Param('id') id: string) {
|
||||
// return this.conversationsService.findOne(+id);
|
||||
// }
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateConversationDto: UpdateConversationDto) {
|
||||
|
||||
@ -16,8 +16,8 @@ export class ConversationsService {
|
||||
return await this.conversationModel.create(createConversationDto)
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all conversations`;
|
||||
async findAll():Promise<ConversationDocument[]> {
|
||||
return await this.conversationModel.find().exec()
|
||||
}
|
||||
|
||||
async findP2p(senderId:string, targetUserId:string){
|
||||
@ -27,9 +27,9 @@ export class ConversationsService {
|
||||
});
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} conversation`;
|
||||
}
|
||||
// findOne(id: number) {
|
||||
// return `This action returns a #${id} conversation`;
|
||||
// }
|
||||
|
||||
update(id: number, updateConversationDto: UpdateConversationDto) {
|
||||
return `This action updates a #${id} conversation`;
|
||||
|
||||
@ -5,7 +5,7 @@ export type ConversationDocument = Conversation & Document;
|
||||
export enum ConversationType{
|
||||
P2P='p2p',
|
||||
GROUP='group'
|
||||
}
|
||||
}
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class Conversation {
|
||||
|
||||
@ -2,24 +2,22 @@ import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/commo
|
||||
import { UsersService } from './users.service';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
import { ApiOperation } from '@nestjs/swagger';
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
constructor(private readonly usersService: UsersService) {}
|
||||
|
||||
// @Post()
|
||||
// create(@Body() createUserDto: CreateUserDto) {
|
||||
// return this.usersService.create(createUserDto);
|
||||
// }
|
||||
|
||||
@ApiOperation({ summary: 'Get all users' })
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.usersService.findAll();
|
||||
async findAll() {
|
||||
return await this.usersService.findAll();
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: 'Get a user by id' })
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.usersService.findOne(id);
|
||||
async findOne(@Param('id') id: string) {
|
||||
return await this.usersService.findById(id);
|
||||
}
|
||||
|
||||
// @Patch(':id')
|
||||
|
||||
@ -15,10 +15,15 @@ export class UsersService {
|
||||
return await this.userModel.create(createUserDto)
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all users`;
|
||||
async findAll():Promise<UserDocument[]> {
|
||||
return await this.userModel.find().exec()
|
||||
}
|
||||
|
||||
async findById(id:string):Promise<UserDocument | null>{
|
||||
return await this.userModel.findById(id).exec()
|
||||
}
|
||||
|
||||
// NOTE:this is used in another module
|
||||
async findOne(name: string):Promise<UserDocument | null> {
|
||||
return await this.userModel.findOne({name}).exec()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user