本文介绍了具有名称类型的猫鼬字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此结构验证并保存 Passport 配置文件:
I am trying to validate and save a Passport profile with this structure:
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"的属性,它是为猫鼬类型保留的.我该如何解决这个问题?
The e-mail has a property called 'type', which is reserved for a mongoose type. How do I solve this?
推荐答案
您需要使用对象定义字段:
You need to define the field using an object:
type: {type: String}
这篇关于具有名称类型的猫鼬字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!