From 11cb249b5d50306ac94e2cf1c32f69c06ee013d9 Mon Sep 17 00:00:00 2001 From: Jaehyun Yoon Date: Mon, 9 Dec 2024 17:10:08 +0900 Subject: [PATCH] refactor: [BE] add promise return type to findByCategory function and update toJSON method additional fields (#41) --- apps/server/src/models/event.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/server/src/models/event.ts b/apps/server/src/models/event.ts index 35517dc..dc12822 100644 --- a/apps/server/src/models/event.ts +++ b/apps/server/src/models/event.ts @@ -1,9 +1,10 @@ import { getModelForClass, plugin, prop, ReturnModelType } from '@typegoose/typegoose' import mongoose from 'mongoose' import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses' -import { User } from '@/models/user' import mongoosePaginate from 'mongoose-paginate-v2' +import { User } from '@/models/user' + @plugin(mongoosePaginate) export class Events extends TimeStamps { static paginate: mongoose.PaginateModel['paginate'] @@ -57,6 +58,7 @@ export class Events extends TimeStamps { return { _id: this._id, name: this.name, + address: this.address, location: this.location, startDate: this.startDate, endDate: this.endDate, @@ -71,7 +73,11 @@ export class Events extends TimeStamps { } } - public static async findByCategory(this: ReturnModelType, category: string, options: object) { + public static async findByCategory( + this: ReturnModelType, + category: string, + options: mongoose.PaginateOptions, + ): Promise>> { return await this.paginate({ category: category }, options) } }