2
嘿,我試圖做一個數組的數組,兩者都是混合型,這就是我如何建造它貓鼬模式陣列內
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"
}
]
這是爲什麼?
我嘗試讓步驟,其中包括內部字段集,其中包括內部領域,我不明白爲什麼它不是事情的數組。 謝謝!