Node.js 内部有2个混合对象的mongoose架构数组
嘿,我正在尝试将一个数组转换成一个数组,它们都是混合类型,这就是我构建它的方式Node.js 内部有2个混合对象的mongoose架构数组,node.js,mongodb,mongoose,schema,jsonschema,Node.js,Mongodb,Mongoose,Schema,Jsonschema,嘿,我正在尝试将一个数组转换成一个数组,它们都是混合类型,这就是我构建它的方式 var Fields = new Schema({ type: {type: String}, length: {type: Number}, lable: {type: String}, name: {type: String} }); var Fieldsets = new Schema({ label: {type: String
var Fields = new Schema({
type: {type: String},
length: {type: Number},
lable: {type: String},
name: {type: String}
});
var Fieldsets = new Schema({
label: {type: String},
name: {type: String},
fields: {type: [Fields]}
});
var Steps = new Schema({
order: {type: Number},
name: {type: String},
fieldsets: {type: [Fieldsets]}
});
var FormSchema = new Schema({
name: {
type: String,
default: '',
trim: true
},
created: {
type: Date,
default: Date.now
},
steps: {type: [Steps]}
});
然后我用这个,通过邮递员(chrome扩展)来发布这个
{
"name": "Reg Form",
"steps": [
{
"order": "1",
"name": "Login Information",
"fieldsets": {
"label": "Username and password",
"name": "username_password",
"fields": {
"type": "text",
"length": "256",
"lable": "Username",
"name": "username"
}
}
},
{
"order": "2",
"name": "Check check",
"fieldsets": {
"label": "Email and age",
"name": "email_age",
"fields": {
"type": "text",
"length": "256",
"lable": "email",
"name": "email"
}
}
}
]
}
结果是:
[
{
"_id": "534964bd55da09f8144d43ac",
"__v": 0,
"steps": [],
"created": "2014-04-12T16:07:25.780Z",
"name": "Reg Form"
}
]
为什么呢
我正在尝试制作一个包含内部字段集的步骤数组,其中包含内部字段,我不明白为什么不这样做。
谢谢 我对这一点是全新的,但请尝试代替
步骤:{type:[steps]}
执行steps:[steps]
和字段