我有这样的猫鼬模式:
代码:
let a = {
email: {
type: String,
//match: /^\S+@\S+\.\S+$/,
required: true,
unique: true,
trim: true,
lowercase: true
},
password: {
type: String,
required: true,
minlength: 6
},
name: {
type: String,
index: true,
trim: true
},
surname: {
type: String
},
address: String,
role: {
type: String,
//enum: roles,
default: 'user'
},
picture: {
type: String,
trim: true
},
namespace: {
//type: Schema.Types.ObjectId,
ref: 'User'
}
};
let b = Object.keys(a).map((el) => {
return { [el]: a[el].type ? a[el].type.name : typeof a[el] === "function" ? a[el].name : "int" };
})
表格:
Table user {
email String
password String
name String
surname String
andress String
role String
picture String
andress Int
}
我需要能够将方案转换为表格。 我必须使其全部自动化,而不必先进行更正检查。
例如,注释为enum: roles
和type: Schema.Types.ObjectId
的零件给我几个问题。
一些建议?