From 17c15c6322c9c4bd63b19291668be4ceff2244d1 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 26 Jan 2021 19:05:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=E5=86=9B=E5=9B=A2=EF=BC=9A=E9=82=80?= =?UTF-8?q?=E8=AF=B7=E5=88=97=E8=A1=A8=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/db/UserGuildApply.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shared/db/UserGuildApply.ts b/shared/db/UserGuildApply.ts index ce53b4e16..c416cfc63 100644 --- a/shared/db/UserGuildApply.ts +++ b/shared/db/UserGuildApply.ts @@ -28,10 +28,7 @@ export default class UserGuildApply extends BaseModel { // 创建申请或邀请 public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) { const applyCode = genCode(10); - const doc = new UserGuildApplyModel(); - const update = Object.assign(doc.toJSON(), { applyCode, roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id, type }); - delete update._id; - const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate({ applyCode }, update, { upsert: true, new: true }).lean(); + const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate({ roleId: role.roleId, guildCode: guild.code, type }, { $set: { roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id }, $setOnInsert: { applyCode }}, { upsert: true, new: true }).lean(); return result; }