我正在try 使用Passport struct 保存以下配置文件:

http://passportjs.org/guide/profile/

这就是我提出的方案:

// Define the schema.
schema = new mongoose.Schema({
    // The name of this user, suitable for display.
    displayName: String,
    // Each e-mail address ...
    emails: [{
        // ... with the actual email address ...
        value: String,
        // ... and the type of email address (home, work, etc.).
        type: String
    }],
    // A unique identifier for the user, as generated by the service provider.
    id: String,
    // The name ...
    name: {
        // ... with the family name of this user, or "last name" in most Western languages ...
        familyName: String,
        // ... with the given name of this user, or "first name" in most Western languages ...
        givenName: String,
        // ... and with the middle name of this user.
        middleName: String
    },
    // The provider which with the user authenticated.
    provider: String
});

邮箱有一个名为"type"的属性,它是为mongoose 类型保留的.我该如何解决这个问题?

推荐答案

需要使用对象定义字段:

type: {type: String}

Node.js相关问答推荐

使用NodeJS在S3上传文件时的格式问题

如何使用MongoDB在Node.js 中向数组中添加项?

无法从MongoDB文档中保存的对象数组中获取对象的属性

Cypress.io - 如何等待返回调用属性的方法的结果?

有没有办法判断 UUID 是否是使用 node.js 中的特定命名空间生成的?

node_modules/preact/src/jsx.d.ts:2145:22 - 错误 TS2304:找不到名称SVGSetElement

使用 create-expo-app 时如何更改 webpack-config.js 中的哈希函数?

将 AllowDiskUse true 添加到 node.js 中的 MongoDB 聚合?

Node.js |如何在微服务之间转发标头?

我怎样才能让`git`失败而不是要求提供凭据

为什么我的 Heroku Express API 数据是持久的,即使它只是来自一个变量

使用新react 18.0.0 的 create-react-app my-app redux 错误

如何在 node 调试器中禁用第一行中断

NODEJS 进程信息

TypeError:请求路径包含未转义的字符,我该如何解决这个问题

tsconfig.json 中模块类型的区别

PhoneGap/Cordova Android 开发

为什么 Node.js 被命名为 Node.js?

deno vs ts-node:有什么区别

AWS Lambda:如何将秘密存储到外部 API?