修复mongodb{}对象不更新问题

This commit is contained in:
lik
2026-06-02 10:03:17 +08:00
parent f3cd769d7d
commit 12be175ce8
2 changed files with 6 additions and 1 deletions

View File

@@ -56,6 +56,8 @@ class HandlerUser {
return ResponseUtil.badRequest(ctx, "缺少微信登录凭证 code 或 appId"); return ResponseUtil.badRequest(ctx, "缺少微信登录凭证 code 或 appId");
} }
let app = config.app[appId]; let app = config.app[appId];
if (!app) { if (!app) {
return ResponseUtil.badRequest(ctx, `未配置 appId: ${appId}`); return ResponseUtil.badRequest(ctx, `未配置 appId: ${appId}`);
@@ -104,6 +106,7 @@ class HandlerUser {
user.app[appId] = { role: ["user"], wxopenid: openid }; user.app[appId] = { role: ["user"], wxopenid: openid };
} }
user.app[appId].wxopenid = openid; user.app[appId].wxopenid = openid;
user.markModified('app');
} else { } else {
return ResponseUtil.internalError(ctx, "用户不存在"); return ResponseUtil.internalError(ctx, "用户不存在");
} }

View File

@@ -68,6 +68,8 @@ const UserSchema = mongoose.Schema(
// 带wxopenid // 带wxopenid
app: { app: {
type: mongoose.Schema.Types.Mixed,
default: {}
}, },
// 元数据 - 系统管理信息 // 元数据 - 系统管理信息